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 08:59 PM
unexpected token error
if i am doing like this it is not creating any record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 09:29 PM
What is the type of your ui action ?
If it's a client side ui action ,use "g_user.userID" to get the current user's sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 09:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 01:33 AM
From the pic,your ui action runs on the server side , gs.getUserID() is the right way to get the current user's sys_id .
It seems that you are runinng a table api to insert?update a record .
The script runs on server side so you don't need to use table api..just use gliderecord to insert or update the record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 12:59 AM
Thanks for your efforts @Mohith Devatte. Here i am sharing the code which worked for me. Actually there was a problem with concatenation of string.