Can you have a global variable in a script include that can be used in all of your functions?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 06:35 AM
Can you have a global variable in a script include that can be used in all of your functions?
I want to have a Global variable that controls logging for the functions. I don't want to have the same variable in each function. I want 1 location to set it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 06:38 AM
Hi @Dave
Follow below link:
How to access global variable in catalog client scripts?
Feel free to mark correct, if your issue has been resolved, so it ends up in solved queue.
Will be helpful for others looking for the similar query.
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 06:49 AM
Aman
Thank you for your quick response. I made an error in my question. I want to create a global variable in a Script Include, not a client script.
I had tried before with:
var logging = true;
inside the Initialize function but that didn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 06:55 AM
Hi,
You can create script include with variables values and you can use it in server/client side script.
Take a look at - Scripting 101: Script Includes - Class vs Classless
Also, another option for script include, may be you can assigned the value in system property and you can use it server side script.
Thanks,
Sagar Pagar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 11:04 AM
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 🙂
Aman Kumar