Email Inbound Action script not able to populate caller_id field in Incident Form

practice test
Tera Contributor

Good Morning All, 

I have Email inbound action that opens a Incident when an email send to ServiceNow instance(no conditions set for testing purposes). I am trying to populate some fields from the email body text however I am not able to populate caller_id field in Incident form. Since caller_id is a reference field I am trying to pass a sys_id, however it does not work. To test it, I am even tried to put a hard coded sys_id and it still does not work. 
I also created a client script to pass hardcoded sys_id and it does populate the reference field. I just can't get it to populate from inbound action. 


Here is the code for inbound action:

current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;

//Commented out hard coded sys id

//current.caller_id = 'dc413c53db7845d03e411c76489619fa';

current.category = "Alert / Error / Warning";
current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";
current.assignment_group = email.body.assignmentgroup;

current.u_call_back_number = "xxxxxxxxxx";

4 REPLIES 4

Allen Andreas
Administrator
Administrator

Hi,

So there's already an inbound action that will create an incident from an email, I'd recommend checking that out and the advanced section to see the script used and use that as an initial example.

Here's a sample of the script:

current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;

current.category = "inquiry";
current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";

if (email.body.assign != undefined)
   current.assigned_to = email.body.assign;

if (email.importance != undefined) {
   if (email.importance.toLowerCase() == "high") {
		current.impact = 1;
		current.urgency = 1;
   }
}

if (current.canCreate())
	current.insert();

So some of what you have follows this, so you may have already done this step and if so, great!

With that said, you'd want to ensure you have a current.insert(); line as well and that the inbound email address used for testing is associated to a real sys_user record.

Additionally, you'd want to ensure that there are no UI Policies or Client Scripts on the Incident that could be clearing this value or that you don't have other things going on that could be causing issues (such as other inbound actions or before insert business rules, etc.).

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hello,

Unfortunately, you mentioned the wrong individual in your reply. Please respectfully double-check in the future as time has been spent here trying to help you.

Additionally, I mentioned more than just the script, please re-read my reply above.

You're not providing enough information for us to assist you as out of box, the same script is available in another inbound action and would work just fine.

If you're having issues with yours, please explain further troubleshooting you've done and more information related to the logging and other methods you've used to check your values.

You're not including the full script, either, so that's causing us to reply with suggestions that you're finding "irrelevant", but we don't know that because you're not attaching the true information.

It's recommended to attempt troubleshooting with logging yourself, disable this inbound action and use the out of box inbound action and see how that works for you, include full, true information, and also include more information about the inbound action to include any conditions, etc.

We don't know if you have a duplicate inbound action that you built that is catching these records and the script isn't fully populated, so you're seeing issues. We don't know what testing you've done to include a statement saying the user is a legit user registered on your sys_user table. We don't know that you've checked the audit log for the record and have verified the user wasn't already populated, but then cleared by another process, perhaps.

As you can see...there's quite the list of things here and we need more information...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Ian Mildon
Tera Guru

Are you sure the action was triggered?

I have created quite a few inbound email actions and the majority are using "hardcoded" caller_id's that are set via sys_id values, like your example here:

current.caller_id = "dc413c53db7845d03e411c76489619fa";

Although I tend to use "" for this rather than '', so it may be the script behaves differently.

practice test
Tera Contributor

@Allen Andre Indefenzo 
I am using that same code, you can see there is really not much of a difference. Also I did not include all my code in there, so there is current.insert() call at the end of my code.  Since Inbound actions are on the server side, I did check business rules and did not see anything that would clear caller_id field

@Ian Mildon 
It sure does get triggered, cause It does open a new Incident, however caller_id field is not getting populated. When I did client script with the same sys_id, it populates the field fine, I am just not able to update that field from Server side with inbound action