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.

How to Auto fill "Display Name" Field.

Chaitanya Redd1
Tera Guru

I have created a form in that I have added few fields in that I have created "Account" , "Display Name" & "Name" Fields.

In this I need help whenever I request new project I will select "Account" field and fill " Name" Fields. So, here I need to automatically "Display Name" filed has to fill Example : " Account - Name" fields values in Display Name filed.

find_real_file.png

find_real_file.png

Please help the field values has to be in this sequence in Display Name Filed :  " Account - Name"

 

1 ACCEPTED SOLUTION

try this code :

 is backed name of name field "short_description" ??

is yes then :

   var account= g_form.getReference("u_account").short_description;
    var name= g_form.getValue("short_description");
   
  
   
        var displayName = account +"-"+name;
   
    g_form.setValue("u_display_name",displayName);

 

===================================== 

but if  backend name of "name" field is another then:

   var account= g_form.getReference("u_account").short_description;
    var name= g_form.getValue("backend name of name field"); 
   
  
   
        var displayName = account +"-"+name;
   
    g_form.setValue("u_display_name",displayName);

View solution in original post

10 REPLIES 10

Khozema Attar1
Tera Guru

Onchange or on submit script must be written as per the requirement most preferrably onsubmit

var name=g_form.getValue('database value of name');
var account=g_form.getDisplayValue('databasevalueof account'); // this line of code works on Service Portal

or

var account = getDisplayBox('databasevalue of account').value; // this line works in it view


var dn=account+"-"+name
// alert(dn);
g_form.setValue('database value of display name',dn);