How to attach new created contract record number in RITM Variable

wefw
Tera Contributor

Hi, 
We have a Contract number Variable in RITM which is a ReadOnly field.

wefw_1-1744014075547.png

we have a flow designer where we are creating new Contract record after closing the catalog task. So once the Contract record is created we need to update that record number in RITM Contract number variabale. For these we have written one script in update record action.

wefw_0-1744014002388.png

But this is not working, while we are testing we are getting an error as 
Error: "Cannot read property "request_item" from null,Detail: Cannot read property "request_item" from null"

Any lead Please

1 ACCEPTED SOLUTION

@wefw 

the way how you are updating the RITM record is not correct.

sc_item_option_mtom table stores all the variable associated with RITM, you can use lookup action in flow designer and can update the variables value in "sc_item_option"

Something like this

update ritm variable in flow.gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

17 REPLIES 17

@wefw 

are you updating the record in subflow or main flow?

If in subflow then are you passing RITM sysId as input to subflow? if yes then ensure you give that correctly at line 2

Also you didn't update the line as per what I mentioned since that variable is reference type.

I assume step 23 is creating record into contract table, the same table being referred by that variable

    ritm.variables.contract_number = fd_data._23_create_record.record.sys_id.toString();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

yes we are creating contract and updating record in subflow.
23 step is creating contract record
yes same table is being referred by that variable

in Subflow we are passing this

wefw_0-1744020393748.png

 

@wefw 

so it's a reference type input to RITM table so update as this

var ritm = new GlideRecord('sc_req_item');
var ritmSysId = fd_data.subflow_inputs.sys_id.toString();
if (ritm.get(ritmSysId)) {
    ritm.variables.contract_number = fd_data._23_create_record.record.sys_id;
    ritm.update();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

wefw_0-1744021659905.png

Still i am getting this error as Index 1 out of bounds for length 1