How can I auto populate email field, when user field filled.

ND7
Kilo Sage

Dear Expert,

How can I proceed with this requirement? Once the user field name is entered, the email field should automatically populate. Please help Thank you so much. Appreciate your help. 

find_real_file.png

2 ACCEPTED SOLUTIONS

did you try putting alerts ?

make sure your back end names of variables are correct  

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
 
    var user = g_form.getReference('name', userDetails);
    
    function userDetails(user) {
alert(user.email);
        g_form.setValue('email', user.email);
    }
}

View solution in original post

Thank you Ankur, I will try this Catalog lookup for sure. BEST

 

View solution in original post

20 REPLIES 20

No problem ! Have a good weekend 

this feature only worked on the AGENT side but on the customer portal it did not work??? Please HELP 

Ankur Bawiskar
Tera Patron
Tera Patron

@ND

You can do this without scripting using Catalog lookup definition

Create a catalog lookup definition

Catalog Data Lookup Definition on any table, eliminating Catalog Client Scripting

Regards
Ankur

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

Thank you Ankur, I will try this Catalog lookup for sure. BEST

 

UndertoadNW
Tera Contributor

We solved for this using a business rule.  This rule updates the email address automatically any time the username field changes.  I'm just guessing at the field names, but this should give you an idea.

When to Run:  "UserName" Changes and the "UserName" is not empty.

Insert = True ,  Update = True

 

Actions:  Set field values "EmailAddress" "Same as" "UserName.EmailAddress"