FWD Inbound Rule Caller ID

Navneet3
Tera Expert

Hello 

I have an issue with FORWARD inbound rule which is setting the CALLER to GUEST.

I have gone through the community posts and I am using the following script  which sets the CALLER from the body of the email but the incident keeps setting the user to GUEST. I am so frustrated why the CALLER can't be set from the body of the email. Please see the attached for the inbound rule and the script.

I need help PLEASE.  I need to resolve this ASAP.

Thank you so much in advance.

 

 

22 REPLIES 22

I will suggest that you delete the file you attached, it contains sys_id information and other log details that are not interesting to share.

Can you capture the logs again? This time filter by "Test Community Navneet3 -"

    gs.log("Test Community Navneet3 - Inbound email received from: " + email.from);
    gs.log("Test Community Navneet3 - Inbound email subject: " + email.subject);
    gs.log("Test Community Navneet3 - Inbound email body: " + email.body_text);

    var data = email.body.submittedby;
    gs.log("Test Community Navneet3 - Submitted by: " + data);
    var lastname = data.split(",")[0].toString();
    gs.log("Test Community Navneet3 - Last name: " + lastname);
    var firstname = data.split(",")[1].toString();
    gs.log("Test Community Navneet3 - First name: " + firstname);
    var fullname = firstname + ' ' + lastname;
    gs.log("Test Community Navneet3 - Full name: " + fullname);
    var gr = new GlideRecord('sys_user');
    gr.addQuery('u_full_name', fullname);
    gr.addQuery('active', true);
    gr.query();

    if (gr.next()) {
        current.caller_id = gr.sys_id;
        gs.log("Test Community Navneet3 - Caller ID: " + current.caller_id);
    } else {
        gs.log("Test Community Navneet3 - User not found");
    }


I took advantage and added other logs, because in what you sent, the data came as undefined, that is, it is not receiving any value.

OMG - I totally forgot, I have deleted the file. Thank you for reminding me

Here is the file.

Hi

Could you please look at ROW 5? its complaining about line 7 in the script.

 

thank you

 

@Navneet3 Following line is causing error in your script.

 

var data = email.body.submittedby;

Looks like your email body doesn't contain a key submittedby due to which it is printing an undefined on the following line

 

gs.log("Test Community Navneet3 - Submitted by: " + data);

 

Also, due to the same reason it is crashing at the following line.

 

    var lastname = data.split(",")[0].toString();

 

Since the data object is undefined, calling split method wouldn't return an array here and trying to access 0th index here will result in script crashing at this line.

 

Hope this helps.

Hi Sandeep, Could you please help with a solution?

 

thank you