We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Decision Table returning null (result_elements missing) when called from Flow Designer field script

adityagalan
Tera Contributor

Hi Everyone,

 

I’m working on auto‑routing RITM/sc_task assignment groups based on the requester’s country.
To manage this logic, I created a Decision Table with two inputs:

  • u_user → Reference (sys_user)
  • u_catalog_item → Reference (sc_cat_item)

And one result column:

  • u_assignment_group → Reference (sys_user_group)

In Flow Designer, inside Update Record → Assignment group (script field), I call sn_dt.DecisionTableAPI().getDecision(). But the flow fails with:

 

Error: Cannot read property "result_elements" from null,Detail: Cannot read property "result_elements" from null

 

It seems getDecision() is returning null.

Has anyone faced this issue when calling the Decision Table directly from a Flow Designer field script?
Do reference inputs require strictly sys_id strings in Flow Designer scripts, or is this a limitation of DecisionTableAPI when used inside FD?

 

Note: I'm aware of Flow Logic: Make a decision, but my requirement is to use script in FD field(Assignment Group field).

Any guidance or working examples would be really helpful.

5 REPLIES 5

Shruti
Giga Sage

Hi,

 

Try this

 

   var answer = '';
   var dt = new sn_dt.DecisionTableAPI();

   var response = dt.getDecisions('<sysidofdecisiontable>', inputs);

   for (var i = 0; i < (response && response.length); i++) {
       var result = response[i];
       var result_elements = result.result_elements;
       var u_groups = result_elements.u_groups.getValue();

       if (u_groups) {
           answer = u_groups;
           break;
       }
   }

   return answer;

Ankur Bawiskar
Tera Patron

@adityagalan 

try this

if (fd_data.trigger.request_item.variables.u_category == 'Other') {
    return '6bd31b9c1b284a101bc76280604bcb95';
} else {

    var dt = new sn_dt.DecisionTableAPI();
    var inputs = {};
    inputs.u_user = fd_data.trigger.request_item.requested_for.toString();
    inputs.u_catalog_item = fd_data.trigger.request_item.cat_item.toString();
    var response = dt.getDecision('f6c37daa83f23a50ff2e9bcfeeaad3f2', inputs); // Decision builder sys_id
    var result = response.result_elements.u_assignment_group;

    return result;

}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@adityagalan 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hello @Ankur Bawiskar 

 

I’m still getting the same error:


Error: Cannot read property "result_elements" from null (Detail: Cannot read property "result_elements" from null).

 

The same script works as expected in Workflow, but it doesn’t behave the same way in Flow Designer.

 

Regards,

Aditya