Last name ,first letter autopopulate

User_267
Tera Contributor

I have created a variable - name

And another variable- last name

So whenever the user enters last name(ex-john) then first letter "j" should populate in name field.

Require client script for this.

5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@User_267 Here is the script you should use.

Screenshot 2023-10-13 at 9.14.42 PM.png

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

   //Type appropriate comment here, and begin script below
   var lastName = g_form.getValue('last_name');
   
   if(lastName!='')
   g_form.setValue('name',lastName[0]);//First letter of last name
   
}

Tested on my PDI and it produces the intended result.