- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 12:26 AM
Hello Everyone,
This is regarding one of my requirement 🙂
I want to use one of the variable value which is in one of the function in script include.
I want to use this variable value in another function which is in the same script include.
How to call one function to another function in the same script include and how to use the variable value of one function to another function in same script include.
Also , the variable value is getting returned to the glide ajax call in the function and I want to use the same variable value in another function in same script include.
Script include is the Client callable one.
Please help with the logic and code.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 07:31 AM
unless Test function returns this you cannot access it
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 12:35 AM
you can call function of same script include within another function using this syntax and also you can pass the value to that function which is getting called
this.myFunction(variable);
It will be nice if you share the existing scripts and what you tried and what's not working as per expectations
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 05:13 AM
Thank @Ankur Bawiskar for the reply..
so as per the syntax you have mentioned - this.myFunction(variable);
I am taking one example here -
First function
TEST : function (){
var abc = ' ' ;
doing some logic
return abc ; /// returning the abc variable in this function
}
Second function :
Demo : function (){
// need to use the abc variable in this function
this.TEST(abc);
}
can we do like this, I need to use the value of abc variable (which is in TEST function) in DEMO function.
should I store - this.TEST(abc) to any variable like below ?
var xyz = this.TEST(abc);
Do I need to pass the abc value as a parameter in DEMO function as well while declaration like below ?
Demo : function (abc){
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 05:45 AM
it would be like this
var xyz = this.TEST();
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 06:07 AM
so @Ankur Bawiskar ,
var xyz = this.TEST(); // adding this line in my DEMO function , will do the job ?
as I need to use the variable value "abc" in DEMO function which is stored in TEST function.
Thanks !