Setting current user in Requested for field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 12:48 AM
Hello All,
I have created a ui action on cmdb_ci table and ordering a catalog item by this button. I am able to set this value as static but not able to set a dynamic value (current logged in user). can anyone suggest me what changes i can made to my code fill "Requested for" field value as current logged in user.
Here is my code segment:-
request.setRequestBody("{'sysparm_id':'e08d99ae9713111005827f200153af15','sysparm_quantity':'1','variables':{'requested_for':'62826bf03710200044e0bfc8bcbe5df1','configuration_item':'829e953a0ad3370200af63483498b1ea','description':'Record created from Rest API Explorer'}}");
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 01:00 AM
'requested_for':gs.getUserID()
Replace the requested_for value with gs.getUserID() as above.
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 08:34 PM
Hello Jaheerhattiwale,
(As i am not hardcore developer) I have tried this but i guess this can be used while you are "simple coding" but in this case these parameters are in Json form so we need to try some other approach to set values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 09:14 PM
@Sandeep Sharma2 You should try following code:
var requestBody = {
'sysparm_id':'e08d99ae9713111005827f200153af15',
'sysparm_quantity':'1',
'variables':{
'requested_for': gs.getUserID(),
'configuration_item':'829e953a0ad3370200af63483498b1ea',
'description':'Record created from Rest API Explorer'
}
}
request.setRequestBody(JSON.stringify(requestBody))
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 09:59 PM
@Sandeep Sharma2 Did you try this?
ServiceNow Community Rising Star, Class of 2023