10 views

Description

Creating an incident manually via UI form view, the Location field is set as Caller's location. However, creating an incident via email set no value in Location field and it remains empty. Expectation is to set the Location as Caller's location even when an incident is created via email.

Release or Environment

Applicable to all releases

Cause

The reported UI behaviour is controlled by either of Client Script or UI Policy utilities which is not applicable to email processing as it happens in the backend. When checking the respective Email Inbound Action, platform utility which creates an incident from emaill, we do not see any logic defined for setting Location field value.

Resolution

In order to set the Location field value on incident form as Caller's location, we need to use scripting. Go to the respective Inbound Action (System Policy > Email > Inbound Actions) and check script field.

When script field is empty, saving the record with below script will answer your purpose otherwise kindly append your script (within function wrapper) with below piece of code except 1st and last statement.

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {

    var sender_email = email.from;
    current.location = getLoc(sender_email);

    //Fetch user location
    function getLoc(user_email) {
        var gr = new GlideRecord('sys_user');
        gr.addQuery('email', user_email);
        gr.query();
        if(gr.next()){
            return gr.location; //returns user's location sys_id
        }
    }
})(current, event, email, logger, classifier);



Article Information

Last Updated:2020-11-22 01:51:06
Published:2020-11-22