Document ID in mail script

Kushi
Tera Contributor

Hello, 

Can someone help me with using a Document ID field in email script. I need to fetch triggerID (document ID field) which is on assessment table. I need to fetch 'use case name' field from use case table using 'trigger ID'.

 
 Kushi_0-1735037100664.png

 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Kushi 

email is on which table?

is it on Assessment Instance Question table?

if yes then it should work

If the email is on Assessment Instance then update as this

gr.get(current.trigger_id);

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

@Kushi 

 

Hope you are doing good.

Did my reply answer your question?

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

Runjay Patel
Giga Sage

Hi @Kushi ,

 

You can use below script in your email script.

// Get the triggerID value from the current assessment record
var triggerID = current.triggerID;

// Check if triggerID exists
if (triggerID) {
    // Query the Use Case table using the triggerID
    var useCase = new GlideRecord('use_case_table'); // Replace 'use_case_table' with the actual table name
    if (useCase.get(triggerID)) {
        // Fetch the Use Case Name
        var useCaseName = useCase.use_case_name; // Replace 'use_case_name' with the actual field name
        email.body += 'Use Case Name: ' + useCaseName;
    } else {
        email.body += 'No Use Case found for the given Trigger ID.';
    }
} else {
    email.body += 'Trigger ID is missing in the assessment record.';
}

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------