How to create a request on behalf of another user - Service Catalog

Faiz Firaz
Kilo Contributor

Hi,

I am using the Service Catalog API (namespace : "sn_sc") to create a service request (REQ#) with a request item (RITM#) attached to it using REST API explorer. Below is the request body used ( only mandatory variables for this item is used) ;

{ "sysparm_quantity" : 1,

"variables" : {
"requestor" : "test user",
"project_details" : "test project",
"week_to_unfreeze_time" : "08-03-2021",
"reason_for_unfreeze" : "reason comes here"
}
}

From the above, the request gets created for the user who is sending the request. However, I want to raise this request on behalf of another user. How can this be done?

What I tried :

  • Passing the "requested_for" variable both inside and outside of the "variables" field in the request. 
  • Tried passing the user name and also, the user id in requested_for field.

How can this be done please.

Thanks,

Faiz.

 

1 ACCEPTED SOLUTION

@Faiz Firaz 

Please remember this point

1) for reference variable you should always send the sys_id

2) for choice variable always send the choice value

3) for checkbox send true/false

To set the OOB requested_for field on REQ with your user add sysparm_requested_for

{ "sysparm_quantity" : 1,

"sysparm_requested_for" : "4ae3ab0753101200ed11da86a11c0881"

"variables" : {
"requestor" : "UserSysIdHere",
"project_details" : "test project",
"week_to_unfreeze_time" : "08-03-2021",
"reason_for_unfreeze" : "reason comes here"
}
}

Regards
Ankur

 

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

View solution in original post

26 REPLIES 26

Hi @Ankur Bawiskar,

I tried the above approach. Still I get the Requested By field empty

Thanks,

Faiz.

Hi there,

Looking at your image, the requested_by field is not empty. It contains a value. You can see this because the I icon is shown. For example confirm by looking at the XML, you will see that actually it has a value. Though, somehow not a valid value.

So double check the value you are entering to that field. Does it contain a sys_id or a wrong value? Is the sys_id actually valid, have you confirmed the sys_id against the sys_user table?

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi,

OOB there is no requested by field on REQ table

is that a custom field created by you on REQ table?

As per your image there is some value inside it

Can you share that field configuration from dictionary

Regards
Ankur

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

@Ankur Bawiskar below is the screenshot of that. find_real_file.png

Hi,

so the field name is requested_for but the label is changed

that is fine

then the approach I shared should work fine in setting the value

Did you set the correct user sys_id for sysparm_requested_for

{ "sysparm_quantity" : 1,

"sysparm_requested_for" : "4ae3ab0753101200ed11da86a11c0881"

"variables" : {
"requestor" : "test user",
"project_details" : "test project",
"week_to_unfreeze_time" : "08-03-2021",
"reason_for_unfreeze" : "reason comes here"
}
}

Regards
Ankur

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