Inbound email action - assign the value in field based on the lookup of a value in a different field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 11:48 PM
Inbound email action: I am looking for some help looking up and applying a value based on the body of the inbound email.
My inbound email has a name:value pair which is the location that I want to be applied to the location field in the incident form.
The issue I have is that the incident form requires the location reference field to be the value in the "name" field of the location record
My inbound email is providing a value in the "value pair" which is also a unique value in the Location Record and that field in the location record is called "common_name"
So for example my location record might be.
name=SYD - Sydney Airport
common_name=Sydney Airport
The inbound email will be like this.
location:Sydney Airport
I want to lookup and populate the location Field in the incident with the value in the name field from the location record
in this example I want it to be set to "SYD - Sydney Airport"
If someone could assist that would be greatly appreciated
Cheers
Phil
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2022 12:11 AM
Hi, in your action script you would normally use GlideRecord to lookup the matching record based on the data that you do have (your name:value pair) and populate this into the current.fieldName.
Assuming there is an exact field match then you can use the get() method, although it is still best to encapsulate in an if statement to ensure you result is correct. Something like
var yourRef = yourNameValuePairValue;
var gr = new GlideRecord('yourTable');
if(gr.get('nameOfReferenceField', yourRef)) {
current.theTargetField = gr.sys_id;
}