Need to populate display name based user given values

Haresh Haru
Tera Expert

Hello All,

Like I have 3 fields are there which are single line text fields, so when user enter a value in first name as haresh and lastname as haru then the third field should population haresh haru as the display name in portal catalogue form..

 

Regards,

Haresh 

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You need 2 Onchange Client scripts running on first name and last name fields. On each script read the current field and combine it with second field and populate to third field

Something like below

var fName = g_form.getValue('<first name field>');
var lName = g_form.getValue('<last name field>');
g_form.setValue('<Full name field>', fname + lName);

 

-Anurag

View solution in original post

8 REPLIES 8

@Haresh Haru 

Try this

var fname = g_form.getValue('first_name');
  var lname = g_form.getValue('last_name');
  var ans = fname +  ' '  + lname.toString().toUpperCase();
  g_form.setValue('display_name',ans);
-Anurag

Hello @Anurag Tripathi 

 

Its working as expected but if the user is giving first name also it has come first letter as capital like this 'haresh haru'  then it showuld show "Haresh HARU (Guest)"

can you please help me to get fisrtname first letter as upper case other letters in lower case

@Haresh Haru 

USe this

 

var fname = g_form.getValue('first_name');
  var lname = g_form.getValue('last_name');
  var ans = fname.toString().toLowerCase();+  ' '  + lname.toString().toUpperCase();
  g_form.setValue('display_name',ans);

 

 

Please mark the response as correct if this answers your question.

-Anurag

sushantmalsure
Mega Sage
Mega Sage

you can write on change () catalog client script on related catalog item.

OnChange() function to be called on lastname , then set the 3rd field using value of first name and last name.

You may want to check if first name is not empty.

You can set this client script to run UI type as All or Service Portal and applies on catalog item view as true.

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure