how to pull caller email on short description in incident form ?

VedhR
Tera Contributor

Whenever caller is selected in incident form that caller email id should be displayed in short description and work notes fields.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@VedhR 

you can use onChange client script on caller_id field and set the short description and work notes

sample script below

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

    g_form.getReference('caller_id', function(caller) {
        if (caller) {
            var email = caller.email;
            var shortDescription = g_form.getValue('short_description');
            var workNotes = g_form.getValue('work_notes');
            
            // Update Short Description
            g_form.setValue('short_description', 'Caller Email: ' + email + ' - ' + shortDescription);
            
            // Update Work Notes
            g_form.setValue('work_notes', 'Caller Email: ' + email + '\n' + workNotes);
        }
    });
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@VedhR 

you can use onChange client script on caller_id field and set the short description and work notes

sample script below

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

    g_form.getReference('caller_id', function(caller) {
        if (caller) {
            var email = caller.email;
            var shortDescription = g_form.getValue('short_description');
            var workNotes = g_form.getValue('work_notes');
            
            // Update Short Description
            g_form.setValue('short_description', 'Caller Email: ' + email + ' - ' + shortDescription);
            
            // Update Work Notes
            g_form.setValue('work_notes', 'Caller Email: ' + email + '\n' + workNotes);
        }
    });
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Uncle Rob
Kilo Patron

Its worth asking why?
Why email in the short description of every single incident?  

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @VedhR 

 

What is the business use case for this? Adding a caller in the Short description did not add any value, where you already have the caller field on the incident form. You will increase technical debt.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************