- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 03:09 AM
I have a requirement.
On a Catalog form, there is a Change Request reference field. So, when Catalog form gets submitted along with the Change Request number, an RITM gets submitted.
So, the requirement is, this RITM should be then linked on the Change Request Related Section (change number which we gave on the Catalog form).
How should I achieve this with Code on WorkFlow ? I have created a workflow on sc_req_item table. But I will use Run script action and will write code.
I have written some code but I am not sure of the working. Please help.
workflow.info('Run Script Checking 3' + current.variables.change_request_number_1);
var cNumber = current.variables.change_request_number_1;
var cChange = new GlideRecord("change_request");
cChange.addQuery('number', cNumber);
cChange.query();
if(cChange.next()) {
current.sc_req_item = cChange.sys_id;
current.update();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 04:45 AM
then you need to set parent field on RITM with the CHG
try this
Note: I don't know the variable type is string type
var cNumber = current.variables.change_request_number_1; // I assume this variable is reference type
var cChange = new GlideRecord("change_request");
cChange.addQuery('number', cNumber);
cChange.query();
if (cChange.next()) {
current.parent = cChange.sys_id;
current.update();
}
If the variable is reference type then simply use this
var cNumber = current.variables.change_request_number_1; // I assume this variable is reference type
current.parent = cNumber;
current.update();
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
01-28-2025 04:45 AM
then you need to set parent field on RITM with the CHG
try this
Note: I don't know the variable type is string type
var cNumber = current.variables.change_request_number_1; // I assume this variable is reference type
var cChange = new GlideRecord("change_request");
cChange.addQuery('number', cNumber);
cChange.query();
if (cChange.next()) {
current.parent = cChange.sys_id;
current.update();
}
If the variable is reference type then simply use this
var cNumber = current.variables.change_request_number_1; // I assume this variable is reference type
current.parent = cNumber;
current.update();
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
01-28-2025 04:55 AM
Thank you for marking my response as helpful.
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
01-28-2025 04:57 AM
Super amazing. Thank you so much. You are very intelligent. God bless you