i want to populate a requester as a current log in user in a service portal

Kunal Balode
Tera Contributor

i want to populate a requester as a current log in user in a service portal please someone guide me on this

4 REPLIES 4

Suryansh Verma
Tera Contributor

@Kunal Balode 

 

If your requestor field is a reference field to 'sys_user' field then in the default value of the requestor field put

javascript:gs.getUserID();

it will auto-populate the current logged-in user name.

Brian Lancaster
Tera Sage

Set the default value of the field to like in the screenshot below.

BrianLancaster_0-1675107806902.png

 

SatyakiBose
Mega Sage

Hello @Kunal Balode 

You need to use the gs.getUserID() method.

A sample code is:

  1. Create an onload client script on the form that is supposed to populate the field.
  2. Enter the code as:
function onLoad() 
{ var userID = g_user.userID; if (g_form.getValue('caller_id') == '') g_form.setValue('caller_id', userID); }

Here we are assuming caller_id is the field on the form that is supposed to populate the value.

You need to check this on your instance.

Prateek kumar
Mega Sage

Check this out:

https://www.servicenow.com/community/now-platform-forum/how-to-auto-populate-with-current-user/m-p/1...


Please mark my response as correct and helpful if it helped solved your question.
-Thanks