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

Need to make reply to an Approval Request, "Approve" or "Reject", case insensitive.

OC21
Tera Contributor

Hi,

 

I am looking to change how users are able to reply to an email for an Approval Request so that the reply is case insensitive. Right now, the users must reply in all lowercase to an Approval Request in their emails. I would like it so that they can type "approve" or "reject" in any case.

 

Example: Approve, approve, APPROVE, etc. Currently, only lowercase "approve" or "reject" works.

 

Approval Request email notification.png

 

This is part of the Actions I have in the Inbound Email Action:

 

if (email.subject.match(/approve/i) || email.body_text.toString().toUpperCase().startsWith('APPROVE')) {
current.state = "approved";
}

if (email.subject.match(/reject/i) >= 0 || email.body_text.toString().toUpperCase().startsWith('REJECT')) {
current.state = "rejected";

 

 

 

This is the original:

 

if (email.subject.indexOf("approve") >= 0 || email.body_text.toString().toUpperCase().startsWith('APPROVE')) {
current.state = "approved";
}

if (email.subject.indexOf("reject") >= 0 || email.body_text.toString().toUpperCase().startsWith('REJECT')) {
current.state = "rejected";

 

 

I'm not proficient in scripting so any assistance is appreciated.

Thank you.

1 REPLY 1

kamlesh13
Tera Contributor

Hi @OC21 ,

 

Please try below code I have utilised this in one of my implementation.

 

if (/approve/i.test(email.subject) || email.body_text.toLowerCase().startsWith('approve')) {
    current.state = "approved";
}

if (/reject/i.test(email.subject) || email.body_text.toLowerCase().startsWith('reject')) {
    current.state = "rejected";
}

 

Regards,

Kamlesh