Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Client script not working to auto populate the requestor field on form load

NayeemSk
Tera Contributor

I had created a client script to Populate requested name as soon as form loaded with the value from current user. But when I go ahead to load a new form, it stills hows empty. Attached code screenshot.

 

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

You could do this with one line:

g_form.setValue('requestor_name', g_user.userID);

but note that the field/variable name 'requestor_name' must be exactly correct (case-sensitive) and since g_user.userID returns a sys_id, this field/variable must be a reference type to the sys_user table.