To call one of the script include function in another function of the same script include

Dinesh90
Tera Contributor

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.

1 ACCEPTED SOLUTION

@Dinesh90 

unless Test function returns this you cannot access it

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

@Dinesh90 

unless Test function returns this you cannot access it

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Dinesh,
We can store varaibles in property objcet like(this.variableName)
Example:

myFunc: function(){
        this.a="Test"; // Store variable value into properties of the object (this)
        this.b = "Test1";

        return this.a+" "+this.b;
    },

    myDemo: function(){
        var d = this.myFunc(); // call function
        gs.log("Function variable a: "+ this.a);
        gs.log("Function variable b: "+ this.b);
       
    },

If my solution is correct, please mark as Helpful

Regards,
Keshav

Dinesh90
Tera Contributor

 @Ankur Bawiskar Thanks Ankur it worked