Populating the assigned_to using employee_number via REST API

BillyS
Tera Contributor

We are trying to populate the assigned_to when creating an incident record using a post to the table API.

POST https://xxxxxxx.service-now.com/api/now/table/incident

We are able to use the user's name, or email, or user_id to do this, but we want to be able to use the employee_number field.  

Example: For the user Abraham Lincoln who is in the Presidents group and has the employee_number of 16 we get the following results.

This works:
{
"assignment_group": "Presidents",
"assigned_to": "abraham.lincoln"
}

This does NOT:

{
"assignment_group": "Presidents",
"assigned_to": "16"
}

Response Body

{
  "error": {
    "message": "Operation Failed",
    "detail": "Operation against file 'incident' was aborted by Business Rule 'Abort changes on group^097174f6db4601109bded2984b96199a'. Business Rule Stack:Abort changes on group"
  },
  "status": "failure"
}

On the assigned_to field in the incident table we have added the following to the Dictionary Entry Override and it allows us to look up a user on the form by their employee_number, but doesn't work with the API  "ref_auto_completer=AJAXTableCompleter,ref_ac_columns_search=true,ref_ac_columns=employee_number,ref_ac_display_value=false"


Any suggestions?  Thanks All!

8 REPLIES 8

Allen,

FYI... We were able to overcome this challenge by modifying the oob business rule "Abort changes on group" in the incident table.  We added the condition Opened by.Web service access only is not true.

Hi Allen - did you ever figure out why email and username worked but not others?  

Great reply!

I had a similar issue in a business rule, so with your help my solution was:

 

(function executeRule(current, previous /*null when async*/) {

    gs.info("=== debug comments ==> " + gs.getUser().getID());
    current.assigned_to.setValue(gs.getUser().getID());

})(current, previous);

Hi,

Thanks. If it was helpful, please also mark it as Helpful.

Take care! 🙂


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