Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

Setting current user in Requested for field

Not applicable

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

14 REPLIES 14

Not applicable

SandeepSharma2_0-1670388421711.png

unexpected token error

SandeepSharma2_1-1670389048880.png

if i am doing like this it is not creating any record

HI @Community Alums 

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.

 

 

Not applicable

SandeepSharma2_0-1670392213164.png

 

@Community Alums 

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.

 

 

Not applicable

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.

SandeepSharma2_1-1670403583120.png