Business rule that writes a variable form one ticket into the message of another ticket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 03:50 PM
Hello,
The scenario is this;
I have a catalog item in our Service Portal called Request Help. In this Request Help catalog item we ask for a reference ticket number. This reference ticket number would be an existing ticket in our ServiceNow instance. When a new Request Help catalog item is submitted I want to write this new ticket number into the reference ticket work notes.
I am able to do this in a Flow, but there is already a Flow attached to this catalog item.
So I think I need to do this with a business rule and a custom script, but my business rule script skills are minimal at best. Can anyone give me some tips, resources, or examples that might help.
Thank you,
Dan
- Labels:
-
Script Debugger
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 04:40 PM
Hi,
I am assuming you want to copy the RITM number of the new request help item into the related incident's worknote field.
Business rule:
Script:
(function executeRule(current, previous /*null when async*/) {
var incident = current.variables.ticket; //replace 'ticket' with name of your ticket reference field
var incidentGr = new GlideRecord('incident');
incidentGr.get(incident);
if(incidentGr){
incidentGr.work_notes= ''+current.number;
incidentGr.update();
}
})(current, previous);
Hope this helps.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 11:56 AM
Hi,
This worked great for an incident.
I know I wasn't specific, but I am trying to do this for a existing requested item.
Any idea how I would do that?
Thank you,
Dan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 12:06 PM
Sure,
Should be:
(function executeRule(current, previous /*null when async*/) {
var ritm = current.variables.ticket; //replace 'ticket' with name of your ticket reference field
var ritmGr = new GlideRecord('sc_req_item');
ritmGr.get(ritm);
if(ritmGr){
ritmGr.work_notes= ''+current.number;
ritmGr.update();
}
})(current, previous);
Let me know if any issues
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 12:15 PM
Hi,
Okay, that totally makes sense.
The script is trying to create a new RITM to update rather than update an existing RITM. Is that possible?
I am guessing the new RITM is created by the "new GlideRecord" statement. Yes?
How do I find an existing?
Thanks so very much for all you help.
Thank you,
Dan