Script is returning null in flow designer

Nagendra Babu32
Tera Contributor

Hi all,

 

I created a flow as shown in below image .

 

NagendraBabu32_4-1711091430459.png

 

 

In create catalog task, I tried to set the field assignment group through scripting to get the group value from decision table but it was returning null for below code::

 

var UserCompany = fd_data._1__get_catalog_variables.requested_for.company.sys_id;
var UserCountry = fd_data._1__get_catalog_variables.requested_for.country;
var dt = new sn_dt.DecisionTableAPI();
    var inputs = new Object();
    // define decision inputs
    //if(current.request_item.variables.itss_std_vsvar_requested_for){
    inputs['u_company'] = fd_data.trigger.request_item.requested_for.company.sys_id;
    inputs['u_country'] = fd_data.trigger.request_item.requested_for.country;
    // make decision
    var assignment = dt.getDecision('5a9fe9862f0102106d9a49e72799b66f', inputs);
    return assignment.sys_id;
NagendraBabu32_6-1711091705415.jpeg

 

 

 

 

 

I tried of getting same group name through decision table in fix script . It was returning the group sys_id.

NagendraBabu32_0-1711091258553.png

 

NagendraBabu32_2-1711091329461.png

 

 

Please Can anyone suggest what I was missing in the code?

 

 

7 REPLIES 7

Already It was already pre configured flow so they need the changes. So I used the script instead of "Get decision step".

Community Alums
Not applicable

But still I would recommend to add a "Get Decision" step before that one, and to use the output in this one instead of scripting against an API. Think about maintainability and future compatibility.

Maybe variable names don't actually match what is in the script?

I would introduce Flow Variables into the equation, one for company and one for country.

I would set those variable with help of a "Set Flow Variables" flow logic.

Than I would use those variables (vs. actions) in the script.

It makes all of it more robust, because renaming actions would not brake references to those actions in scripts and it would allow you to view the values used and forwarded to the API when debugging the flow.

 

I mean assignment being null means that no decision could be taken - which might be because unexpected data is forwarded to the input object.