Service Catalog REST API - How to Pass Requested For Field - Ebonding

patbishop
Mega Guru

I am attempting to use the Service Catalog - Add to Cart, and Checkout APIs to ebond two instances.  Essentially, a user will fill out a Service Catalog Request, it gets submitted into one instance (REQ and RITM) Then if the RITM needs ebonded, an Assignment Group is triggered to initiate the ebond, builds a JSON file and then runs the Add to Cart and Checkout APIs.

This is all working, except I cannot seem to get the Requested For field to populate on the REQ and RITM on the second instance.  I've tried with Display Name, sys_id (from the second instance) and nothing works.  I must not be building it properly in my JSON. Does anyone have any ideas?

Example JSON:

{"sysparm_quantity": "1","requested_for":"ba571269137ad7c063fe7d176144b0f4","variables":{"requested_for":"ba571269137ad7c063fe7d176144b0f4","u_on_behalf": "No","u_action_requested": "Citrix Application Access - Add","u_description": "TEST","user_name": "TEST_USER","first_name": "TEST","last_name": "TEST","u_site_address": "TEST","u_site_name": "TEST","u_department": "4edd930b13e292009f84b6246144b08c","u_speedchart": "TEST","u_set_id": "TEST"}}
7 REPLIES 7

The problem that I'm having is that the workflow looks at the Department table to determine approvals etc. This information is pulled from the user record, so when I attempt to add the Requested For via Table API, it may be too late and the workflow is already canceled.

patbishop
Mega Guru

My previous approach will not work. The workflow is triggered and run and I cannot seem to update the "Requested For" field after the ticket is submitted from the Cart and Checkout. 

It appears that the Cart API may not be the best option. 

Has anyone leveraged CartJS with a REST message to POST to another instance?  I see in the CartJS details that it allows for the setting of the "Requested For" field, but I essentially need to bundle all of my data and variables up from MY instance, and then add it to the Cart and Checkout on the OTHER instance. 

Does anyone have any ideas?

Gabriel3
Giga Contributor

The correct parameter is sysparm_requested_for:

{
    "sysparm_quantity": 1,
    "sysparm_requested_for": "fc221927dbcb3700a4cc980c8a96198b",
    "variables": {
        "var_name": "var_value",
    }
}