Sending Mails through ServiceNow Page

AbdulMajidK8082
Tera Contributor

I have been trying to send the mails to fetched email through  scripts but in server script it is not propagating the input action                                                                                                                                                                      Client Script                                                                                                                                                                                         

c.sendEsignRequest = function() {
if (!c.sys_id) {
c.message = "⚠️ Please enter a sys_id.";
return;
}
if (!c.email) {
c.message = "⚠️ No email found for this user.";
return;
}

c.message = " Sending request...";
console.log("DEBUG: Sending email to", c.email);

// Wrap payload in {data: ...} for .update()
c.server.update({
data: {
action: 'sendRequest',
sys_id: c.sys_id,
email: c.email
}
}).then(function(resp) {
var result = resp.data || resp;
if (result.success) {
c.message = " E-sign request sent successfully!";
c.sys_id = '';
c.email = '';
} else {
c.message = " " + (result.error || "Failed to send email");
}
});

2 REPLIES 2

Nehal Dhuri
Mega Sage

Hello @AbdulMajidK8082 
To better assist you, could you please clarify the specific business requirement or use case you're aiming to address with this implementation? Understanding the context will help us suggest the most suitable approach and design considerations.

Looking forward to your response.

Please hit like and mark my response as correct if that helps

AbdulMajidK8082
Tera Contributor

i was fetching the email of the user based on the sys_id of the record in a table

and was trying to send the mail to that particular user for e-sign