Script Includes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
How To Make Script Include Private and Public ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi @SarthakK,
script include doesn't do anything itself, to execute the code it must be called. And these calls can be allowed/restricted.
You can set the scope - all scopes or just the given (custom) scope and also client callable.
Is it what you asked? If not, could you possibly elaborate a bit more on what you want to achieve?
100 % GlideFather experience and 0 % generative AI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello @SarthakK ,
In short simply use "_" To Make Script Include Private,
For ex :
myPublicFunction: function() {
// This function is public and can be called externally.
this._myPrivateFunction();
gs.info("Public function");
},
_myPrivateFunction: function() {
// This function is private and only accessible within this script include.
gs.info("Private function");
},
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello @SarthakK ,
By simply using _ (underscore) before your script include function it will make script include function as private and without underscore script include function remains public .
Private function script include which can be accessed/called from same script include or child script include, which means it cannot be called in background script or Fix script directly.
example : Private function in script include
_getData:function()
{
//your code
}
example : public function in script include
getData:function()
{
//code
}
If this helps you then mark it as helpful and accept as solution.
Regards,
Aditya,
Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
@Aditya_hublikar and @yashkamde
Are you sure that adding "_" in the function name makes it automatically private?
I just tested in a background script calling a scoped script include from global and it worked. While marking the script include callable from the scope only it was restricted...
The same functions
var sandstormUtil = Class.create();
sandstormUtil.prototype = {
initialize: function() {},
myPublicFunction: function() {
return this._myPrivateFunction();
},
_myPrivateFunction: function() {
return "Private function";
},
type: 'sandstormUtil'
};
When having a script include callable from all scopes, then calling from global returns:
When having a script include callable from the script include's scope only, then calling from global returns:
This is how I understood setting privacy for a script include and haven't found any documentation nor article about the "_" making it private. It seems to me that it is only a naming convention but not any functional property.
Could you please share something to show me how the "_" makes it private? I want to know what I am doing wrong and to learn your way.
Thank you in advance!
EDIT: I tried with the getData() versus _getData() with the same result:
What am I doing wrong?
100 % GlideFather experience and 0 % generative AI
