I need to link RITM on Exisiting Change Request (in Related section) - Help

AbdurRahmanSnow
Giga Guru

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 created.

 

So, the requirement is, this RITM should be then linked on the Change Request Related List (change number which we gave on the Catalog form).

 

How should I achieve this with Run Script 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 in Workflow but it is not working. Please help.

workflow.info('Run Script Checking 3' + current.variables.change_request_number_1);
workflow.info('Line 2' + current.sc_req_item); //Here, current means RITM table.

var cNumber = current.variables.change_request_number_1;

var cChange = new GlideRecord("change_request");
cChange.addQuery('sys_id', cNumber);
cChange.query();

if(cChange.next()) {
    cChange.sc_req_item = current.sc_req_item.sys_id;
    cChange.update();
}
1 ACCEPTED SOLUTION

@AbdurRahmanSnow In your workflow run script, can you simply put the following code.
Preview
 
current.parent = current.variables.change_request_number_1+'';
current.update();

View solution in original post

7 REPLIES 7

Sandeep Rajput
Tera Patron
Tera Patron

@AbdurRahmanSnow There is no such OOTB field with name sc_req_item on the change request table. Are you sure that such a field exist on your instance?

Sandeep, I am assuming it, because the back-end name of the RITM is sc_req_item. But on the Change Request, I was not able to find RITM back-end name. 
Please check. Would be grateful for that

@AbdurRahmanSnow If you want to show the RITM in the related list of Change request then you can do the following change inside your workflow run script.

 

Screenshot 2025-01-28 at 5.51.20 PM.png

var ritm = current.sc_req_item.getRefRecord();
ritm.setValue('parent', current.variables.change_request_number_1);
ritm.update();

Sandeep, thank you so much. I really appreciate.
But will you please give the complete code? I am totally confused. I would be grateful for that.

Because here "current" means RITM table, because I will use this code on Workflow Run script and Workflow is created on sc_req_item table