The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Body of the Received email need to be update in comments/worknotes of the record

suuriyas
Tera Contributor

HI Community,

 

I have a requirement, in HR Case record whenever we receive an email reply from user then it needs to update in the comments/worknotes .

I have written a inbound action script for it but it is not working as expected.

email get added to the activity log of the record but the email body is not getting updated in the comments/worknotes.

 

For example: email received is updated but the body of the email is not getting updated in record's comments/worknotes.

what am i missing 

suuriyas_0-1756378986339.png

Part of the script:

//update on active cases
if (current.getTableName() == "sn_hr_core_case" && current.getValue('state') != 3 && current.getValue('state') != 7) {

        //gs.info('xxx1 '+ mailaddress);
    if (current.getValue('u_sender_email') == mailaddress || current.opened_for.email == mailaddress || current.opened_by.email == mailaddress || current.subject_person.email == mailaddress) {

       
        //if rejection email, set state back to work in progress
        if ((email.subject.indexOf(REJECT_SUBJ) !== -1) ||
            (email.subject.indexOf(REOPEN_SUBJ) !== -1)) {
               

            //only for awaiting acceptance state
            if (current.getValue('state') == 20) {
               
                current.state = 18;
            }
        }
        //If accept email close the case.
        if (email.subject.indexOf(ACCEPT_SUBJ) !== -1) {
            //only for awaiting acceptance state
            if (current.getValue('state') == 20) {
                current.state = 3;
            }
        }
    }
    if (current.subject_person.email != mailaddress && current.opened_for.email != mailaddress && current.opened_by.email != mailaddress && current.u_sender_email != mailaddress && !isInList(current.watch_list, mailaddress)) {
       
        current.work_notes = "reply from : " + mailaddress + "\n\n" + email.body_text;
    } else {
        current.comments = "reply from: " + mailaddress + "\n\n" + email.body_text;
    }
    current.update();

 

 

10 REPLIES 10

Declared mailaddress and its working fine