- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2020 02:52 PM
Whats the proper way to query a glide record so you can populate a reference field when creating an incident with an inbound email action? The code blow is one of my attempts to do so. loc is a string containing a valid location, and its done that way because I'm pulling the string out of emails body. I've tried using 'get' and have made numerous small changes, but when an incident is created any reference fields I try to populate remain empty. So my main question is, whats the correct way to query GlideRecord with a string in order to get a sys_id which is necessary for defining reference fields? Thanks for any advice!
var glide = new GlideRecord('sys_user');
glide.addQuery('location', loc);
glide.query();
if(glide.next()){
current.location = glide.sys_id;
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2020 02:58 PM
Location records are stored in the "cmn_location" table. Replace your script with the below script that I've shared.
var glide = new GlideRecord('cmn_location');
glide.addQuery('name', loc);
glide.query();
if(glide.next()){
current.location = glide.sys_id;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2020 04:13 PM
You are very welcome @wwinter. If you can reproduce this on your Personal developer instance, I can investigate this issue.
- Pradeep Sharma