Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Creating an incident via email does not populate Location value as Caller's location - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Creating an incident via email does not populate Location value as Caller's location
KB0865088

Creating an incident via email does not populate Location value as Caller's location


796 Views Last updated : Apr 8, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

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

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);




The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.