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

Hi @Ankur Bawiskar ,

 

The script is being called through a Scheduled Job, run as 'System Administrator'.

So, Opened By = System Administrator in the RITM.

Although I already have a workaround solution - through workflow I am able to manipulate Opened By to whatever I want.

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

 

--

Thanks,

Subhadeep.


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

Thanks,
Subhadeep Ghosh.

@subhadeep1618 

check this link. it seems it worked as per the logic shared by Tim and Cody

How to set requested for in RITM using Cart APi is it possible? 

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

Revanth Karra
Tera Expert

Dear Subhadeep,

 

Hi @subhadeep1618 . Hope you're doing great! 

 

In my view, I suggest to customize the Opened By field's value, you should use the sysparm_submitter parameter. The sysparm_submitter parameter will specify the user who submitted the RITM. This parameter is writable, so it can be used to customize the Opened By field's value.

 

For example,  sysparm_submitter parameter to customize the Opened By field's value in the RITM:

 

 

var ritm = {
  sysparm_id: "catalog sys id",
  sysparm_quantity: "1",
  sysparm_requested_for: "custom value",
  sysparm_submitter: "custom value", /** IT SHOULD WORK NOW **/
  variables: {
    variable1: "custom value",
    variable2: "custom value",
  },
};

 

 

For example, Once you have created the RITM object, you can submit it to the CartJS API using the following code:

 

 

var cart = new sn_sc.CartJS();
cart.addToCart(ritm);
var checkoutInfo = cart.checkoutCart();

 

 

This will create the RITM with the custom value specified in the sysparm_submitter parameter.

 

Kindly, please mark my solution as Helpful/Correct, if applicable. If I could help you with your Query then, please hit the Thumb Icon and mark as Correct!!!

 

Thanks & Regards, 

Revanth. K

Product Test Automation Engineer

Hi @Revanth Karra ,

 

Unfortunately sysparm_submitter is NOT customizing Opened By field's value in RITM.

 

Thanks,

Subhadeep.


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

Thanks,
Subhadeep Ghosh.

Hi Subhadeep,

 

I know this is a long time ago thread, did you find the answer finally?

Meanwhile I am facing another issue that is related to the CartJS API. I use the API in a workflow to submit catalog request. The request and request item can be created successfully. But the flow designer flow associated with the catalog item will not be triggered. If I copy the script to Script Background and run it, it works perfect. Do you have any idea of what makes it fail to trigger the flow when running with the workflow?

 

Thanks,

Endmost