Updating the RITM fields using cart API is not working

Krika
Kilo Contributor

Hi,

I need to update the RITM fields for which I'm using a BR with cart api, but RITM fields are not getting updated.
Here is my BR condition:

find_real_file.png
here is my script:

find_real_file.png
I need this to parent field to be updated on my RITM and request table also how to achieve this?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

BR is on sn_customerservice_case table

So you want this case record to be populated inside the RITM's parent field and REQ parent field?

If yes then this can be done

after line 13 query RITM and REQ and update; like this

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    
    var ritm = new GlideRecord('sc_req_item');
    ritm.get('request', rc.sys_id);
    ritm.parent = current.getUniqueValue();
    ritm.update();
    
    var req = ritm.request.getRefRecord();
    req.parent = current.getUniqueValue();
    req.update();
    

})(current, previous);

Regards
Ankur

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

View solution in original post

7 REPLIES 7

I guess you are doing it in wrong way.

You are writing business rule on insert of case record and in script you are using current.variables.opened_by

Do you have a variables formatter on case form?

And in the question you wrote update RITM but you dont need cart api to update an ritm.

 

Can you tell your business requirement.

 

when I create a case in sn_customerservice_case table, I will select the asset (reference field) of alm_asset table, the product field will also auto populate the same. After saving the case form my request should be automatically create for the product which I had raised. So to achieve this I'm writing this BR, now request is getting created but the field values are not populating in ritm itself.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

BR is on sn_customerservice_case table

So you want this case record to be populated inside the RITM's parent field and REQ parent field?

If yes then this can be done

after line 13 query RITM and REQ and update; like this

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    
    var ritm = new GlideRecord('sc_req_item');
    ritm.get('request', rc.sys_id);
    ritm.parent = current.getUniqueValue();
    ritm.update();
    
    var req = ritm.request.getRefRecord();
    req.parent = current.getUniqueValue();
    req.update();
    

})(current, previous);

Regards
Ankur

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