- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 06:44 AM
This is my UI Action(incident table) Script
Press the "Not Incident" button in the form header for the generated incident
1. If there is a connected UR, change the status of the UR to "In Progress"
2. If there is no connected UR, I want to create a new UR
Number 2 works normally, but number 1 doesn't work.
What's wrong with my script?
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 07:25 AM
Hi,
update as this
1) you will have to update current record as well once you create the UR
if (current.universal_request == ''){
var gr = new GlideRecord('universal_request');
gr.initailize();
gr.short_description = current.short_description;
gr.description = current.description;
gr.business_service = current.business_service;
gr.cmdb_ci = current.cmdb_ci;
gr.insert();
current.universal_request = gr.number; // I assume universal_request holds number and not sysId
current.update();
action.setReturnURL(current);
action.setRedirectURL(gr);
} else {
var gr2 = new GlideRecord('universal_request');
gr2.addQuery('number', current.universal_request); // I assume universal_request holds number and not sysId
gr2.query();
if (gr2.next()){
gr2.state = 2; // ensure the state choice value is correct
gr2.update();
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 06:59 AM
Hello,
Did you try putting a gs.info() in else loop ?
and also what does current.universal_request return ?is it a number for sure?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 07:25 AM
Hi,
update as this
1) you will have to update current record as well once you create the UR
if (current.universal_request == ''){
var gr = new GlideRecord('universal_request');
gr.initailize();
gr.short_description = current.short_description;
gr.description = current.description;
gr.business_service = current.business_service;
gr.cmdb_ci = current.cmdb_ci;
gr.insert();
current.universal_request = gr.number; // I assume universal_request holds number and not sysId
current.update();
action.setReturnURL(current);
action.setRedirectURL(gr);
} else {
var gr2 = new GlideRecord('universal_request');
gr2.addQuery('number', current.universal_request); // I assume universal_request holds number and not sysId
gr2.query();
if (gr2.next()){
gr2.state = 2; // ensure the state choice value is correct
gr2.update();
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader