Document ID in mail script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 02:46 AM
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'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 02:50 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 09:34 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 11:37 PM
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
-------------------------------------------------------------------------