RITM is not getting approved even the inbound email action got processed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
When I try to approve the RITM through email, the Inbound Email Action is being processed successfully, but the RITM approval state is not changing to “Approved” and remains in “Requested” state.
We are using the OOB Inbound Email Action “Update Approval Request.” As shown in the logs below, after the OOB code executes current.update();, we are getting a null result:
[Approval Email Debug] Update result: null
Could someone please check and help us identify the root cause of why the approval record is not being updated to “Approved”?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Hemagiri,
That null from current.update() is actually a useful clue - it usually means the update got aborted rather than the script not running. A few things I'd check before digging deeper:
1. In your snippet I only see the comments line and current.update(). The OOB "Update Approval Request" action normally has this above it:
if (email.body.approve == "yes") current.state = "approved";
if (email.body.reject == "yes") current.state = "rejected";
Is that still there? And does the reply email actually contain the word "approve" on its own line? If the reply just says "approved" in a sentence or has a signature above it, email.body.approve won't be set and the state never changes.
2. Does the sender (email.from) map to the same sys_user who is the Approver on that sysapproval_approver record? If someone else is replying (delegate, shared mailbox, forwarded mail), the OOB approval business rules will quietly abort the state change, which lines up with the null you're seeing.
3. What state is the approval record in right before the email lands - still Requested, or has it already gone to Approved / No longer required?
4. Any custom before-update business rules on sysapproval_approver that could be calling current.setAbortAction(true)?
If you can share those I'm happy to reproduce it on a PDI and post back the exact fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
1) This is the complete OOB code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Thanks Hemagiri, that narrows it down a lot.
Two things stand out from what you've shared:
1. The log line "Processed 'Update Approval Request', updated sysapproval_approver: Requested Item: RITM0112754" is written by the inbound email engine, not by your script. It only tells you the action ran against the right record - it does not prove the write went through. The null from current.update() is the real evidence: the script reached the update (so validUser() passed and state was set to approved/rejected in memory), and then something on the server rejected the write.
2. The script isn't fully OOB - the validUser() function has a "Defect Fix" customisation that matches user_name against email.from. That's fine and it passed here, so it isn't the cause, just worth knowing.
Also, since the log shows the email was classified as a reply and matched the approval record, the watermark / record matching part is working - the failure is downstream of that.
When update() returns null with no script error, it's almost always one of these:
- A before-update business rule calling current.setAbortAction(true) - including OOB ones, or an OOB one someone has modified. Filter Business Rules by Table = sysapproval_approver, When = before, Active = true, and also check Global rules; look at Updated by rather than just "custom".
- A Data Policy on sysapproval_approver (e.g. comments mandatory on approve/reject). Data policies apply to script updates too and fail them silently unless you look in the logs.
- Something that behaves differently for the sending user. Inbound email actions run in the context of the sender, so a rule that checks roles or gs.getUserID() can pass when you test as admin and block when the approver's email comes in.
Fastest way to find out which - add one line right after the update in a test copy of the action:
gs.info("Approval email update: " + result + " | " + current.getLastErrorMessage());
(where result is the return of current.update()). getLastErrorMessage() gives you the actual abort / data policy reason. Then check System Logs > All for the same minute - a Data Policy Exception or an aborted business rule will show up there.
As a control test, run this in Scripts - Background:
var gr = new GlideRecord('sysapproval_approver');
if (gr.get('<sys_id of the Requested approval>')) {
gr.state = 'approved';
var r = gr.update();
gs.info(r + ' | ' + gr.getLastErrorMessage());
}
If that works as admin but the email path still returns null, the difference is the running user, and the business rule / ACL side is where to look. If it also returns null as admin, it's a rule or data policy on the table and getLastErrorMessage() will name it.
Post back what getLastErrorMessage() says and I'll point you at the exact fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Thanks for your update @musislam ,
please find the below output for the mentioned background script
-
-
-
-
-
