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

find_real_file.png

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);

it worked 50% but here i'm getting one issue

Account's field I have selected 

find_real_file.png

find_real_file.png

 

Accounts filed value is not displaying it's showing undefined.

coming to name part it worked correctly.

use this:

var account= g_form.getReference("u_account").name;

I'm getting error when on New view whenever i'm trying to open new form it's showing error.

find_real_file.png