global variable and global function in script include.

Prateek Tyagi
Tera Contributor

Hi , All

Can any one tell me how can i define global variable and global function in classless script include so that i can use that in another script include and scripts.

Thanks

4 REPLIES 4

Aman Kumar S
Kilo Patron

Classless functions are pretty straightforward, you create them with the same name as class and it can be called from any Server side script.

You can check below article:

Scripting 101: Script Includes - Class vs Classless

For Global variable, have a look at IncidentState script include which comes OOB, for reference how to create Global variables.

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

@Prateek Tyagi 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

 

Best Regards
Aman Kumar

Mohit Kaushik
Mega Sage
Mega Sage

Hi Prateek,

You can achieve it by creating on Demand script includes. Please follow below link to get more understanding on this.

On Demand Script Include | ServiceNow Developer

 

Please mark this as correct and helpful if it resolved the query or lead you in right direction.

Thanks,
Mohit Kaushik
Community Rising Star 2022

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

You can read the below link as well to understand how the variables can be used in other methods of script includes.

Utilities Script Include | ServiceNow Developer

 

Thanks,
Mohit Kaushik
Community Rising Star 2022

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)