inbound email action was not working

RMU
Tera Contributor

i have created a email notification for change to approve and reject via mail on change_Request table, i dont want to use OOTB so using own one and i have created inbound email action on sysapproval_approver table and the script is below my script is not working when i am replying approve/reject but i can see that in notes. i dont why need your inputs please i have kept conditions as subject contains approve.reject.

(function process(email, action) {
    var approval = action.getRecord();
    var body = email.body_text.toLowerCase();
    var subject = email.subject.toLowerCase();
    var decision = "";

    gs.info("Inbound Email Action triggered for approval: " + body+subject+approval.sys_id);

    if (body.contains("approve") || subject.contains("approve")) {
        decision = "approved";
    } else if (body.contains("reject") || subject.contains("reject")) {
        decision = "rejected";
    }

    gs.info("Decision from email: " + decision);

    if (decision) {
        approval.state = decision;
        approval.comments = "Reply from: " + email.from + "\n\n" + email.body_text;
        approval.update();
        gs.info("Approval record updated. New state: " + approval.state);
    } else {
        gs.warn("No valid decision found in email for approval: " + approval.sys_id);
    }
})(email, action);

In Email logs i am getting this error Skipping script 'Change Request Approval', email is a reply, and the record it matches is not in the Inbound Email Action's table
2 REPLIES 2

GlideFather
Tera Patron

Hi @RMU 

why don't you use the OOTB one?

 

but anyways, i think there is some check behind the scenes that validates if the approval decision from email is the same email associated with the user expected to approve/reject it...

 

Example: a record approval is expected from a user with email abc@xyz.com but the approval will be received from email some@else.com then it's ignored... so if you don't have access to the first mailbox, then update the approver user record accordingly.

 

When you check the email logs, what's there, can you share?

 

Last but not least, check the email diagnostics, it might be blocked... 

 

Diagnostics:

GlideFather_0-1755511974151.png

 

 

Properties:

GlideFather_1-1755511997103.png

 

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


RMU
Tera Contributor

email sending is operational and email receiving is operational and i am one of the approver and in email properties i have enabled