How to auto populate field values automatically

poornima batchu
Tera Expert

Hi everyone, 

I created two variables in the portal say requestor name and Requestor Email.

I want the requestor name field to be auto populated while raising a ticket and depending on the requestor name field it should pull the populate the same requestor email address to the next Requestor Email (Field).

 

Please provide your solutions

thanks in advance.

1 REPLY 1

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @poornima batchu ,

For populating the requester name. you can write the onload catalog client script on that catalog item.

Use g_form.setValue('Variablename',g_user.userID);

and to populate the email id on requester email field.

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

    //Type appropriate comment here, and begin script below
    var user = g_form.getreference('requested_for', function(user) {// map the correct field
        g_form.setValue('u_email', user.email.toString());// map the correct field
    });
}

 

if you dont want to write and populate please check the below link

https://www.servicenow.com/community/developer-articles/catalog-data-lookup-definition-on-any-table-...

 

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.