Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

unable to set field with inbound action

Fraggle Rock
Tera Expert

HI they I am creating an incident through an inbound action. The incident is getting created and I am able to set all but one of the fields we are trying to. The field I have problems with is a custom field “u_vendor “on the incident table that references the table core_company.

FraggleRock_1-1710472222749.png

 

When I look at the field after submitting a emai and the inbound action running, I get this error “[SN Utils] Deleted or no display value”

FraggleRock_0-1710472214460.png

 

The inbound action script is very simple the line is

current.u_vendor = email.body.organisation;

 

I have also tried to set it as a VAR first with no luck

 

//Set vendor

    //var vendor = email.body.organisation;

    //current.u_vendor = vendor;

 

The value in the email is correct and matches the value in core_company

any help would be great 

1 ACCEPTED SOLUTION

Amit Verma
Kilo Patron
Kilo Patron

Hi @Fraggle Rock 

 

Your custom field 'u_vendor ' would be expecting the sys_id of the organization as it is referring core_company table. Can you please try setting it like current.u_vendor = 'sys_id of the organization from core_company table'; 

 

You can get the sys_id of the organization received in your email by a Glide Query and then pass it to the variable.

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

4 REPLIES 4

Amit Verma
Kilo Patron
Kilo Patron

Hi @Fraggle Rock 

 

Your custom field 'u_vendor ' would be expecting the sys_id of the organization as it is referring core_company table. Can you please try setting it like current.u_vendor = 'sys_id of the organization from core_company table'; 

 

You can get the sys_id of the organization received in your email by a Glide Query and then pass it to the variable.

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

thanks got it to work with this 

//Set vendor
var ven = email.body.organisation;
var gr = new GlideRecord('core_company');
if(gr.get('name',ven)){
current.u_vendor = gr.sys_id;
}

@Fraggle Rock 

 

Glad you were able to fix your issue. Can you please mark my answer as correct for other to follow.

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Sumanth16
Kilo Patron

Hi @Fraggle Rock ,

 

Try below approach:

 

 

var myemail_body_line1 = email.body_text.substring('0',email.body_text.indexOf('company organization'));

myemail_body_line1 = myemail_body_line1.replace(/\s/g, ''); //Remove all spaces
current.setDisplayValue('u_vendor',myemail_body_line1.split(":")[1]); 

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda