mail script for cc not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I have a mail script to add cc to a notification. The script is getting called as I can see it in the logs and right values. When emails are generated I cannot see that in CC column. How can I fix this? This is a scoped application and both notification and mail script are in the same scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @samadam ,
If your script is executing and logging the correct CC values, but the CC field in the actual email remains empty, here are the key areas to check and fix:
Checklist to Fix Missing CC in Notification Emails
- Use template.print() Instead of email.addAddress()
In scoped applications, the correct way to add CC recipients in a mail script is:
template.print("cc:email@example.com");
email.addAddress("cc", "email@example.com") works in global scope but does not populate the CC field in scoped apps.
2. Ensure Notification Is Using the Mail Script
- Open the Notification record.
- Under "What will it contain?", confirm your mail script is selected in the "Email script" section.
- Make sure the script is not just logging but actually printing the CC line.
3. Check Script Output Format
If you're dynamically generating CCs, make sure the output is formatted like this:
template.print("cc:user1@example.com,user2@example.com");
No spaces between emails, comma-separated.
4. Verify Notification Conditions
- Ensure the notification is triggering correctly and not being overridden by other rules.
- Confirm that the email is sent via the notification, not via a separate email.send() call.
5. Test with a Simple Static Script
To isolate the issue, try a basic mail script:
template.print("cc:test@example.com");
Then trigger the notification and inspect the Email record (sys_email) to see if the CC field is populated.
6. Scoped App Permissions
- Confirm that your scoped app has access to the template object.
- If you're using a custom script include or utility, make sure it's accessible from the notification context.
Debug Tip:-
You can add a debug line to your script to confirm execution:
gs.log("Mail script executed with CC: test@example.com", "MyApp");
Then check the System Logs to verify.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Best,
Anupam.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
What have you tried? I suggest posting your script here. If you are passing a variable as argument to the addAddress method, make sure your variable has the type and value you expect. Other than that it is quite straightforward to add cc from a mail script:
email.addAddress('cc', 'joe.employee@something.com');And by CC column do you mean the copied column in [sys_email]?
