How can I use local storage to store a variable using script include?

Pratik13
Giga Contributor

Hello,

I want to set a variable value using a script include and use the value in another script include.

Can I do this using a local variable?

If yes can anyone provide a simple example?

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

each script include when invoked has it's own scope.

You can pass value from one script include function of Script Include 1 to another script include function of Script Include 2

What is your business requirement

Regards
Ankur

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

Hi Ankur,

Consider two script include A and B.

I want a function in B to be executed only one time depending on the flag value set in A.

In simple terms I want a local storage variable that can be accessed by both A and B.

Hi,

to invoke the function of script include B from script include A you will have to initiate the object and call the function

Regards
Ankur

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

Hi,

I don't want to invoke function in B from A, I want the code in B to be excecuted depending on value of flag set in A.