Inbound Email action trying to set current.cmdb_ci

matthewhobbs25
Kilo Explorer

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

1 ACCEPTED SOLUTION

Glad you got it working, please mark an answer correct to close the thread down.


View solution in original post

7 REPLIES 7

Venkat122
Kilo Guru

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;


}


Dubz
Mega Sage

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.


matthewhobbs25
Kilo Explorer

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.


what value you are getting in email.body.ConfigurationItem