- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2025 11:17 PM
Hello All,
I need a quick help in my inbound action.
I have a scenario in which i have to add CC user to caller field when email is coming from certain user. Can anyone help me what is wrong in my code. Usually, it will be single person in CC, but i tried with array too still there is no luck
if (senderEmail == 'test@gmail.com' ) {
if (email.cc) { // Ensure CC exists
var ccUserEmail = email.cc.toString().trim(); // Convert to string and remove spaces
var ccUserGR = new GlideRecord('sys_user');
ccUserGR.addQuery('email', ccUserEmail);
ccUserGR.query();
if (ccUserGR.next()) { // If user found, assign to Caller
current.caller_id = ccUserGR.sys_id;
}
}
if (senderEmail == 'test@gmail.com' ) {
if (email.cc && email.cc.length > 0) {
var ccEmails = email.cc.toString().split(','); // Convert to list if needed
var ccUserEmail = ccEmails[0].trim(); // Get first email from CC
var ccUserGR = new GlideRecord('sys_user');
ccUserGR.addQuery('email', ccUserEmail);
ccUserGR.query();
if (ccUserGR.next()) {
current.caller_id = ccUserGR.sys_id;
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2025 12:36 AM
Hi @SM123 ,
It seems 'email.cc' is not a valid property, please try using 'email.copied' instead and see if that works.
'email.copied' contains a comma-separated list of email addresses in the Cc.
If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2025 05:47 AM
share the logs to see if CC is present and also if query is giving the correct user
if (senderEmail == 'test@gmail.com' ) {
gs.info('CC email' + email.cc);
if (email.cc) { // Ensure CC exists
var ccUserEmail = email.cc.toString().trim(); // Convert to string and remove spaces
var ccUserGR = new GlideRecord('sys_user');
ccUserGR.addQuery('email', ccUserEmail);
ccUserGR.query();
if (ccUserGR.next()) { // If user found, assign to Caller
gs.info('user found');
current.caller_id = ccUserGR.sys_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
‎02-05-2025 08:36 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