Regrading the Decision table API

Venky Kshatriy2
Tera Contributor

 

Hi Team,

 

The below script working in background but not working in script include

 

Background script:

 

var country_sysids = ['c538b7111b121100763d91eebc0713ec', '4538b7111b121100763d91eebc0713ea'];
        gs.log('the normal country status ='+country_sysids);
        var deciion_sysid = '34283aa12b74e6104da7f81cfe91bf1a';
        var result = [];
        for (var v = 0; v < country_sysids.length; v++) {


            var dt = new sn_dt.DecisionTableAPI();
            var inputs = new Object();
            inputs['u_country'] = country_sysids[v];
            gs.log('static input ='+inputs);
            var response = dt.getDecision(deciion_sysid, inputs);
            gs.log('the response = ' + response);
            var ans = response.result_elements.u_result;
            result.push(ans);
            gs.log('the country status = ' + ans);
            gs.log('Country status =' + result);
            var finalRisk = Math.min.apply(null, result);
            gs.log('total risk rating = ' + finalRisk);
            return finalRisk.toFixed();

        }
 
 
Script include:
var country_sysids = [];
        var result = [];
        country_sysids.push(this.getParameter('sysparam_to'));
        gs.log('To country ='+country_sysids);

      //  var decision_sysid = '34283aa12b74e6104da7f81cfe91bf1a';
       
    
 
        
 
        for (var v = 0; v < country_sysids.length; v++) {
 
            gs.log('working');

                var dt = new sn_dt.DecisionTableAPI();
                gs.log('not worked');
                var inputs = new Object();
                gs.log('inputs ='+inputs);
                inputs['u_country'] = country_sysids[v];
                gs.log('the present inputs = '+inputs);
                var response = dt.getDecision('34283aa12b74e6104da7f81cfe91bf1a', inputs);
                gs.log('working 4 the response = '+response);
                var ans = response.result_elements.u_result;
                result.push(ans);
                gs.log('the country status = '+ans);
           
        }
        gs.log('Country status ='+result);
        var finalRisk = Math.min.apply(null, result);
        gs.log('total risk rating = ' + finalRisk);
        return finalRisk.toFixed();


In script include until this log(gs.log('the present inputs = '+inputs); its printing
after this log its not working

1 REPLY 1

Jon23
Mega Sage

@Venky Kshatriy2 

I would look at your this.getParameter('sysparam_to')' value.

I'm guessing you are passing in a string of comma separated sys_ids. In this case you should do a split on the value to make it an array, and not the push:

 

Try:

Script include:
var country_sysids = this.getParameter('sysparam_to').split();
        var result = [];
//        country_sysids.push(this.getParameter('sysparam_to'));
 
>>> Help others by marking this correct and/or helpful <<<<<<<