Request service catalog item on behalf of someone through Service Catalog REST API

nevo
Kilo Contributor

I'm new to servicenow and I've tried to create a service catalog request from ServiceCatalog REST API. Everything worked fine except I would like to change "requested for" for the item request when adding the item to the cart and checkout. I've searched over the communities here and the only close one is this: service catalog - REST api to create request behalf of requester

I understand variables must be associated with the item so they are specific to the item. My question is whether there's actually an API way to set "requested for" info for the requested item through Service Catalog API (addcart, checkout, submit, etc). By that, I meant you don't have to create some variable to some item, just like when I started a fresh instance, enable two-step checkout, then I could submit order for someone.

Thanks!

1 ACCEPTED SOLUTION

larstange
Mega Sage

Hi



It doesn't look like it is possible using the Service Catalog REST API.



But it is possible using the CartJS api - https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_CJSS-getRequestedFor



var cart = new sn_sc.CartJS();


cart.setRequestedFor("039c516237b1300054b6a3549dbe5dfc")



So you could write your own scripted REST API and route the information through the CartJS api instead. See this for inspiration CartJS API to add multiple item to cart and submit order


View solution in original post

6 REPLIES 6

Ewald
Kilo Contributor

Hello,

Is it possible to achieve such thing now ? (In New York or Orlando)

Jake Cope
ServiceNow Employee
ServiceNow Employee

I've been digging into this issue and appears it 'should' be supported via the API Documentation

 

Reference Service Catalog Guide

https://docs.servicenow.com/bundle/vancouver-api-reference/page/integrate/inbound-rest/concept/c_Ser...

 

See: 'sysparm_requested_for'

 

Sys_id of the user for whom to order the specified item. Located in the User [sys_user] table.

The settings of the glide.sc.req_for.roles and glide.sc.req_for.roles.default properties determine the level at which a user can request items.
     
    These's also this for multiple users
    'sysparm_also_request_for'
     
    There's also a pretty useful parameter under "get_invalid_delegated_users"

    This allows for you to verify if an end user has permissions to be included for the specific catalog item delegated to them.

     

     

    The only issue is after changing these system properties. I've yet to be able to create an SC Order on behalf of another user. The Delegated users comes back blank, indicating there is no permission issue. The problem appears. The User who authorises the API call is the user the SC 'requested for' field defaults to. So if I set a parameter requested for = Abel but the API was authorised with admin, the new SC request gets created with 'request for' field set for admin. I've also done the same the other way round resulting in abel being set instead.

     

    Unless I'm missing something here. It is set within the documentation and so should be supported?