How to autopopulate email address of manager field

swathivaddi
Tera Contributor

Hi,

I have a form on which manager name is a reference type field referencing to User table. (sys_user)

 

There is another field called manager email address which is setup as string field. How to get email address of the selected manager into the email address field?

 

Thank you

1 ACCEPTED SOLUTION

Amit Verma
Kilo Patron
Kilo Patron

Hi @swathivaddi 

 

You can use getReference callback with an On-Change Client Script. Refer below screenshots:

 

AmitVerma_0-1741668023185.png

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    g_form.getReference('manager', getEmail); // Change the manager field name as per your catalog item

function getEmail(manager) { 
    g_form.setValue('email', manager.email); // Change the manager email field name as per your catalog item
}
}

 

Output :

AmitVerma_1-1741668060396.png

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

5 REPLIES 5

PrashantLearnIT
Giga Sage

Hi @swathivaddi 

 

Please have a look at this video for this fulfillment - 

https://youtu.be/mQt4vaX19c8?si=LuIsvqlVnUX6x50H

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************
For More Information, please check details below: In this session, I have explained how to return multiple values from the script include and pass it to the client side. Script Type - Client Scripts & Script Includes Table - Incident Type - onChange based on Caller ====================CLIENT ...