- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2023 04:15 AM
Hi,
Set Caller, Email in incident form. When form loads set Caller Name, Email with client script.
Regards,
Nivedita
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2023 05:55 AM
Here either you can simply dot walking email field from User table on Incident form as 'Caller.Email' from form layout, This will automatically update Email value on Incident table when Caller changes.
2nd solution is by using onChange Client script as below:
function onChange(control, oldValue, newValue, isLoading)
{
if(isLoading || newValue == '')
{
g_form.setValue('caller_id',g_user.userID);
}
var caller = g_form.getReference('caller_id', doAlert);
function doAlert(caller) {
g_form.setValue('u_caller_email',caller.email); // assuming 'Caller Email' [u_caller_email] is custom field to store Caller Email
}
I know getReference() is not recommended by ServiceNow but for fetching 1 or 2 values we can use it.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2023 05:09 AM - edited 01-07-2023 05:10 AM
Hi @niveditakumari ,
What is the source table where you receive the caller from, and what is the expected field and table where email should be set?
best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2023 05:55 AM
Here either you can simply dot walking email field from User table on Incident form as 'Caller.Email' from form layout, This will automatically update Email value on Incident table when Caller changes.
2nd solution is by using onChange Client script as below:
function onChange(control, oldValue, newValue, isLoading)
{
if(isLoading || newValue == '')
{
g_form.setValue('caller_id',g_user.userID);
}
var caller = g_form.getReference('caller_id', doAlert);
function doAlert(caller) {
g_form.setValue('u_caller_email',caller.email); // assuming 'Caller Email' [u_caller_email] is custom field to store Caller Email
}
I know getReference() is not recommended by ServiceNow but for fetching 1 or 2 values we can use it.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2023 12:42 AM
Hi Anubhav,
Thank you so much for your reply.
Can you please confirm field name for email in incident form.
Regards,
Nivedita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2023 01:10 AM
Hi Anubhav,
Script which you given that will work for 'onload' script and 'onchange' script right.
ex - When we load forms then 'CallerID' and Caller 'emaiID' will get autopopulate and when we change CallerID then based on CallerID it will change caller's email id right.
Can you please confirm for this.
Regards,
Nivedita