The CreatorCon Call for Content is officially open! Get started here.

Notification

nameisnani
Mega Sage

Hi Team , 

 

I have a notification which i have created on incident table which is currently sending to assignment group , however i need this notification to be send as CC to incident caller as well  for that i am trying  the below email script however its not sending the email to CC that is caller of the incident.

 

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

        var inc = new GlideRecord('incident');
    if (inc.get(current.incident)) 
    { // Assuming 'incident' is the reference field on the current record
        // Retrieve caller information
        var callerEmail = inc.caller_id.email.toString();
        var callerName = inc.caller_id.name.toString();

        // Add the caller's email as CC recipient
        email.addAddress("cc", callerEmail, callerName);
        // Add your code here

}})(current, template, email, email_action, event);

 

 

can anyone please help me here . 

with screenshots .

 

Thanks in advance . 

1 ACCEPTED SOLUTION

Vishal Birajdar
Giga Sage

Hi @nameisnani 

 

Can you try below script :

 

var userData = new GlideRecord("incident");
userData.addQuery("sys_id",current.sys_id);
userData.query();
if(userData.next()){

        var callerEmail = userData.caller_id.email
        var callerName = userData.caller_id.name
email.addAddress("cc",callerEmail,callerName);

}

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

3 REPLIES 3

Vishal Birajdar
Giga Sage

Hi @nameisnani 

 

Can you try below script :

 

var userData = new GlideRecord("incident");
userData.addQuery("sys_id",current.sys_id);
userData.query();
if(userData.next()){

        var callerEmail = userData.caller_id.email
        var callerName = userData.caller_id.name
email.addAddress("cc",callerEmail,callerName);

}

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Chetan Mahajan
Kilo Sage

Hello @nameisnani ,

                                           

var callerEmail = inc.caller_id.email;
var callerName = inc.caller_id.getDisplayValue();
        
// Add the caller's email as CC recipient
        email.addAddress("cc", callerEmail, callerName);

Kindly mark correct and helpful if applicable

Community Alums
Not applicable

Hi @nameisnani 

 

Please use the below code it is working, i have tested in my PDI.

 

var inc = new GlideRecord('incident');
	if (inc.get(current.number)) 
	{ // Assuming 'incident' is the reference field on the current record
		// Retrieve caller information
		var callerEmail = inc.caller_id.email.toString();
		var callerName = inc.caller_id.name.toString();
		gs.info('Incident Caller '+callerName+'. Incident Email ' +callerEmail );
		// Add the caller's email as CC recipient
		email.addAddress("cc", callerEmail, callerName);
	}

 

 

 

 Screenshot:

K_Sharma_0-1695188076585.png

 

Mark the comment as a correct answer and also helpful if this has helped to solve the problem

Krishna Sharma