- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 01:10 AM
Hi
I trying to be able to send and email and use a template in that email to set various incident fields.
I can set all of them as required accept the Configuration Item
I'm using the following successfully (just part of the code and fields I'm matching successfully)
if (email.body.category != undefined){
current.category = email.body.category;}
if (email.body.description != undefined) {
current.description = email.body.description;}
And then emailing an incident with the following
Category: Other
Description: Long description
ConfigurationItem: Laptop501
I wondering how I can set the Configuration Item
I've tried
if (email.body.ConfigurationItem != undefined) {
current.cmdb_ci = email.body.ConfigurationItem;}
this doesn't work..
I need to use the text version not a sys_id within the email template as the system sending the email only understands the text versions.
Thanks
Matt
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 02:26 AM
Glad you got it working, please mark an answer correct to close the thread down.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 01:36 AM
You can query cmdb_ci table and get the sys_id, try below
if (email.body.ConfigurationItem != undefined) {
var ciDa = new GlideRecord('cmdb_ci');
ciDa.addQuery('name', email.body.ConfigurationItem);
ciDa.query();
if(ciDa.next())
{
current.cmdb_ci = ciDa.sys_id;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 01:40 AM
Hi Mathew,
You can set the value of a reference field like below:
current.cmdb_ci.setDisplayValue('Laptop501');
Edit: or in this case current.cmdb_ci.setDisplayValue(email.body.ConfigurationItem); //you might to add .toString() to convert to string, not sure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 01:53 AM
David
How would I rewrite to have the email.body.ConfigurationItem
I've tried
current.cmdb_ci.setDisplayValue(email.body.ConfigurationItem);
And it doesn't work?
Giri Swamy: your method didn't seem to work either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 01:57 AM
what value you are getting in email.body.ConfigurationItem