script include from ui policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Everyone,
Can we call script include from UI Policy ...? and if yes how and does calling script include from Ui policy make no sence ..?
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
The syntax will remain the same; you just need to add it in the script section.
There are examples in the link above—just follow them. The script syntax remains the same.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @tushar_ghadage ,
You can use glideajax.
The GlideAjax class allows the execution of server-side code from the client. GlideAjax calls pass parameters to the script includes, and, using naming conventions, allows the use of these parameters.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @tushar_ghadage ,
Yes, you can call a Script Include using GlideAjax, similar to how it’s done in a Client Script.
Enable the Run scripts checkbox and add the code under Execute if true or Execute if false, based on your requirement.
Sample code:
var ga = new GlideAjax('MyAjaxSI');
ga.addParam('sysparm_name', 'getStatus');
ga.getXMLAnswer(function(answer) {
if (answer === 'active') {
g_form.setMandatory('u_field', true);
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Yes in "Execute if true" or "Execute if false" you can call script include using GlideAjax
UI policies are used for simple requirement based on fields etc to show/hide, make fields editable/mandatory
If you are planning to use script then better use Client Script
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
