How to set RITM Opened By value with CartJS API?

subhadeep1618
Tera Guru

I am using CartJS API to dynamically create RITM.

Everything is working fine.

But I am not able to customize the Opened By field's value in the RITM by the following code:

var ritm = {
  sysparm_id: "catalog sys id",
  sysparm_quantity: "1",
  sysparm_requested_for: "custom value",
  sysparm_opened_by: "custom value", /** NOT WORKING **/
  variables: {
    variable1: "custom value",
    variable2: "custom value",
  },
};

Can someone please tell me what is the correct parameter name to do this.

In above code, sysparm_opened_by is not working.


Please mark this post as a solution and also as helpful, if this resolves your issue or query.

Thanks,
Subhadeep Ghosh.
10 REPLIES 10

AnveshKumar M
Tera Sage
Tera Sage

Hi @subhadeep1618 ,

You can try using the impersonation in Script. Try the following approach,

 

session.onlineImpersonate("USER_NAME"); //Start impersonation as the user whom you want the opened_by field to be

WRITE ALL YOUR CODE HERE TO CREATE THE RITM

session.onlineUnimpersonate(); //End impersonation 

 

 

Thanks,
Anvesh

I've a much simpler way of doing this instead using session impersonation.

I can simply set the Opened By value in the workflow - it is working perfectly.

But I just wanted to know if this is possible through CartJS API or not.


Please mark this post as a solution and also as helpful, if this resolves your issue or query.

Thanks,
Subhadeep Ghosh.

Ankur Bawiskar
Tera Patron
Tera Patron

@subhadeep1618 

what is being shown currently in opened_by field?

where have you written this script?

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

Currently the name of the user who runs this script (e.g. System Administrator) is being shown.


Please mark this post as a solution and also as helpful, if this resolves your issue or query.

Thanks,
Subhadeep Ghosh.