How to send email to persons in list collector field when related list record get updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 02:47 AM
Hi All,
I have a list collector field on main form as Contact person, Whenever related list record gets updated i need to send email to the contact person of Main form. I wrote email script but its not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 03:17 AM
Hi @Hareesha ,
You cannot do "to"
Only allowed are "cc" and "bcc"
email.addAddress("cc", current.parent.u_contact_person.email, current.parent.u_contact_person.name);
check out this link
https://www.servicenow.com/community/developer-forum/notification-email-script-adding-an-email-addre...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 03:44 AM
Here are the steps to troubleshoot and resolve your issue:
1. Check if the parent record is correctly referenced: Ensure that the parent record is correctly referenced in your script. If the parent-child relationship is not set up correctly, the script may not be able to fetch the parent record.
2. Validate the field names: Make sure that the field names 'u_contact_person.email' and 'u_contact_person.name' exist in the parent record and are correctly spelled.
3. Check the email address: Ensure that the email address fetched from 'u_contact_person.email' is valid. If the email address is not valid, the email will not be sent.
4. Check the email script: Ensure that the email script is correctly written and there are no syntax errors.
5. Check the trigger condition: Make sure that the script is triggered when the related list record is updated. You can do this by adding some debug statements in your script.
6. Check the email logs: If the script is correctly triggered and there are no errors in the script, check the email logs to see if the email was sent successfully.
Here is a sample code for your reference:
javascript
var parentRecord = new GlideRecord('parent_table_name');
if (parentRecord.get(current.parent)) {
var contactPerson = parentRecord.u_contact_person;
if (contactPerson) {
var contactEmail = contactPerson.email;
var contactName = contactPerson.name;
if (contactEmail) {
email.addAddress("to", contactEmail, contactName);
} else {
gs.log('Contact person does not have a valid email address');
}
} else {
gs.log('No contact person found for the parent record');
}
} else {
gs.log('Parent record not found');
}
Replace 'parent_table_name' with the actual name of your parent table. This script fetches the parent record of the current record, gets the contact person from the parent record, and sends an email to the contact person. It also includes some logging statements to help you troubleshoot any issues.
nowKB.com
For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/
For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER