Inbound action : To copy the email content onto the respective RITM

Bindhu1
Tera Contributor

Hi All,  kindly help me to resolve this:

Created an inbound action that copies the email content onto the respective RITM worknotes/activities.
The emails will come from "abc@gmail.com," and the subject will contain the RITM number.

Below is the script for the same (which is failing):
Target table : sc_req_item
Type: New
Condition : To | contains | abc@gmail.com

// Check if the email is from the specific address and contains "RITM"
if (email.subject.toUpperCase().indexOf("RITM") >= 0) {
    
    // Extract the RITM number from the subject
    var ritmNumber = email.subject.slice(email.subject.toUpperCase().indexOf("RITM"), email.subject.toUpperCase().indexOf("RITM") + 10);

    var ritmRecord = new GlideRecord('sc_req_item');
    ritmRecord.addQuery('number', ritmNumber);
    ritmRecord.query();

    if (ritmRecord.next()) {
        ritmRecord.work_notes = "Email from: " + email.origemail + "\n\nSubject: " + email.subject + "\n\nBody: " + email.body_text;
        ritmRecord.update();
    }
}

error in logs says:

Bindhu1_0-1725260350703.png

Thanks!

 


 

1 REPLY 1

Shruti
Mega Sage
Mega Sage
// Check if the email is from the specific address and contains "RITM"
if (email.subject.toUpperCase().indexOf("RITM") >= 0) {
    current.work_notes = "Email from: " + email.origemail + "\n\nSubject: " + email.subject + "\n\nBody: " + email.body_text;
    current.update();

}