Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

orlandocruz
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 @orlandocruz ,

 

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