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.

Default value for a reference field on UI page

Swetha M
Mega Guru

How to set a particular caller name as default value in Caller field(reference) on an incident form UI page.

25 REPLIES 25

Nalin Bisht
Tera Contributor

Step 1: Right-click on the field label, and select configure dictionary.  

 

Screenshot 2023-03-23 172222.jpg

 

Step 2: In the Default Value section, uncheck "Use dynamic default" and enter the sys id of the user you want to have as default on the caller field.

 

Screenshot 2023-03-23 172137.jpg

Hi Nalin,

 

My default value should be only for the incidents on my UI page in Analyst workspace. Remaining incidents in other views need not have this value.

praphul pandey
Tera Contributor

Hi @Swetha M 

 

There are 3 way to do this.

1) Dictionary default value

javascript: gs.getUserID();

OR

 

2) On load client script on that table

 

function onLoad(){

 

 if(g_form.isNewRecord()){

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

 }

 

}

OR

 

3) Display business rule on that table

 

(function executeRule(current, previous /*null when async*/) {

 

 if(current.isNewRecord())

  current.caller_id = gs.getUserID();

 

})(current, previous);

 

Thanks 

praphul kumar pandey

Swetha M
Mega Guru

@Ankur Bawiskar  any advice on this?? 

@Swetha M 

Can you share your business requirement here?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader