- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 04:41 AM
Hello all,
I have created a Script Include and written two functions in it.
one for when Impact on Incident changes, and the other one is when urgency changes.
So, I have created two on Change client scripts and calling the corresponding functions in it using Glide Ajax.
So, now whenever we change the Impact or Urgency, on the form, I am setting up the Priority using these two On Change client scripts.
Now, if the Incident is created from Portal side, and if the Impact is 1 and Urgency is 1, then I need to set the Priority to 1.
So, how can I call these two functions in the BR script?
Regards,
Lucky
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 06:09 AM
update as this and it should work from both the side i.e. client and server (BR)
getImpact: function(impact, urgency, id) {
var impact = JSUtil.nil(impact) ? this.getParameter('sysparm_impact') : impact;
var urgency = JSUtil.nil(urgency) ? this.getParameter('sysparm_urgency') : urgency;
var id = JSUtil.nil(id) ? this.getParameter('sysparm_id') : id;
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', id);
gr.query();
if (gr.next()) {
if (urgency == 1 && impact == 1) {
return 1;
} else if {
urgency == 1 && impact == 2) {
return 2;
}
}
},
Now you can call it like this from server side
var priority = current.priority;
var urgency = current.urgency;
var impact = current.impact;
if(urgency == 1 && impact == 1){
current.setValue('priority', 1);
}
var id = current.sys_id;
var val = new ScriptIncludeName().getImpact(impact, urgency, id);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 08:39 PM - edited 04-25-2025 12:23 AM
Yes Ankur,
It's worked.
Thanks for your time.
Regards,
Lucky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 07:11 AM - edited 04-24-2025 07:13 AM
@Lucky1- Try following... without "global".
new Incident_scripts().getImpact(impact,urgency,current.sys_id);
new Incident_scripts().getUrgency(impact,urgency,current.sys_id);
Let me know if that helped!
Thanks,
Vikas K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 07:22 AM
Hello @Lucky1
Try this:
Script include function:
getImpact: function(impact, urgency, id) {
var impact = this.getParameter('sysparm_impact') || impact;
var urgency = this.getParameter('sysparm_urgency') || urgency;
var id = this.getParameter('sysparm_id') || id;
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', id);
gr.query();
if (gr.next()) {
if (urgency == 1 && impact == 1) {
return 1;
} else if {
urgency == 1 && impact == 2) {
return 2;
}
}
}
Business Rule script:
var urgency = current.urgency;
var impact = current.impact;
var id = current.id;
var impactNew = new Incident_scripts().getImpact(urgency, impact, id);
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 07:54 AM
Hello Juhi,
Can you please tell me what that last line of code does?
Why we are taking that script include returned value to a variable "impactNew" ?
Also, please note that, I need to call two functions in that script include but not only one.
So, can I call the second one similar to first one as you shown?
Regards,
Lucky