Send email Notification when approval is approved or rejected

avinashdubey103
Tera Guru

Hi ,

I have a requirement :
Send email Notification when approval is approved or rejected

I have created a email  notification :

avinashdubey103_0-1697649930862.pngavinashdubey103_1-1697649957688.png

avinashdubey103_2-1697649974184.png



using placeholder in subject and body ,

after that i have created a email script :
code :

(function runMailScript(current, template, email, email_action, event) {
 
// Determine whether the approval was approved or rejected
var isApproved = current.state == 'approved';
 
// Define subject and body variables
var subject, body;
 
if (isApproved) {
    subject = 'Your MS Teams federation - ' + current.number + ' has been approved';
    body = 'Your request for permissions to communicate with partners outside Amdocs via Microsoft Teams ("MS Teams federation") has been approved and is being handled. An email will be sent when you can start using the service.';
} else {
    subject = 'Your MS Teams federation - ' + current.number + ' has been declined';
    body = 'Your request for permissions to communicate with partners outside Amdocs via Microsoft Teams ("MS Teams federation") has been declined.\nReason: ' + current.comments; // Use the comments field for the reason.
}
 
// Set the subject and body in the email notification
email.subject = subject;
email.body = body;
 
 
})(current, template, email, email_action, event);

ss:
avinashdubey103_3-1697650048666.png


Now the email is getting triggerd but like this only :

avinashdubey103_4-1697650150079.png


without the content





2 ACCEPTED SOLUTIONS

Sandeep Rajput
Tera Patron
Tera Patron

@avinashdubey103 Can you try by changing your script as follows.

(function runMailScript(current, template, email, email_action, event) {
 
// Determine whether the approval was approved or rejected
var isApproved = current.state == 'approved';
 
// Define subject and body variables
var subject, body;
 
if (isApproved) {
    subject = 'Your MS Teams federation - ' + current.number + ' has been approved';
    body = 'Your request for permissions to communicate with partners outside Amdocs via Microsoft Teams ("MS Teams federation") has been approved and is being handled. An email will be sent when you can start using the service.';
} else {
    subject = 'Your MS Teams federation - ' + current.number + ' has been declined';
    body = 'Your request for permissions to communicate with partners outside Amdocs via Microsoft Teams ("MS Teams federation") has been declined.\nReason: ' + current.comments; // Use the comments field for the reason.
}
 
// Set the subject and body in the email notification
email.setSubject(subject);
email.setBody(body);
 
 
})(current, template, email, email_action, event);

 

 

 

View solution in original post

Hi @avinashdubey103 ,

Make sure you have updated with correct mail script in notification without any spaces in email script name.
Update email script with below 2 lines

email.setSubject(subject);
email.setBody(body);

Thanks,

Anand

View solution in original post

8 REPLIES 8

@Anand Kumar P 
got this mail :

avinashdubey103_3-1697651809407.png

 

still the content is not coming 

Hi @avinashdubey103 ,

Make sure you have updated with correct mail script in notification without any spaces in email script name.
Update email script with below 2 lines

email.setSubject(subject);
email.setBody(body);

Thanks,

Anand

updated the script as below still the same output :
(function runMailScript(current, template, email, email_action, event) {

// Determine whether the approval was approved or rejected
var isApproved = current.state == 'approved';

// Define subject and body variables
var subject, body;

if (isApproved) {
subject = 'Your MS Teams federation - ' + current.number + ' has been approved';
body = 'Your request for permissions to communicate with partners outside Amdocs via Microsoft Teams ("MS Teams federation") has been approved and is being handled. An email will be sent when you can start using the service.';
} else {
subject = 'Your MS Teams federation - ' + current.number + ' has been declined';
body = 'Your request for permissions to communicate with partners outside Amdocs via Microsoft Teams ("MS Teams federation") has been declined.\nReason: ' + current.comments; // Use the comments field for the reason.
}

// Set the subject and body in the email notification
email.setSubject(subject);
email.setBody(body);


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

You have to call the mail script from the body of the email to get it to run.

Change the body of your email to ${mail_script:script_name}