EdgeVerve / feel

Expression Language for creating and executing business rules in decision table based on DMN 1.1 specification for conformance level 3
MIT License
93 stars 48 forks source link

Decision table execution always return null #32

Closed rzanussigmail closed 11 months ago

rzanussigmail commented 1 year ago

I execute the code as in the exmaple also with table of exemple but always i ahve null en return

const { decisionTable } = require('js-feel')(); var path = require('path'); var root = path.dirname(require.main.filename) //var absolutePath = path.join(root,req.files['dectabv.xls'].path) console.log(root); //console.log(absoluthPath); root = root + "\dectabu.xls"; console.log(root); //const csv = decisionTable.xls_to_csv('./dectabu.xls'); const csv = decisionTable.xls_to_csv('./EBB.xlsx'); console.log(csv[0]); const decision_table = decisionTable.csv_to_decision_table(csv[0]);

console.log(decision_table);

//const payload = {a : 0}; var resu; const payload = {'State' : 'Kerela', 'Bit' : 'b'}; console.log(payload); decisionTable.execute_decision_table("EB", decision_table,payload, (resu)=> { console.log("Rule result: " + resu) });

EB&SP&SP&SP RuleTable&SPCondition&SPCondition&SPAction C+&SPState&SPBit&SPAmount 1&SP"""Karnataka"""&SP"""a"""&SP200 2&SP"""Kerela"""&SP"""b"""&SP300

{ inputExpressionList: [ 'State', 'Bit' ], inputValuesList: [ '"Karnataka","Kerela"', '"a","b"' ], outputs: [ 'Amount' ], outputValues: [ [ '200', '300' ] ], ruleList: [ [ '"Karnataka"', '"a"', '200' ], [ '"Kerela"', '"b"', '300' ] ], hitPolicy: 'C+', context: null } { State: 'Kerela', Bit: 'b' } Rule result: null

davidsamlee commented 1 year ago

The signature in the readme file is wrong, doesn't include the error object so your function is returning the error.

decisionTable.execute_decision_table("EB", decision_table,payload, (**err,** resu)=> { console.log("Rule result: " + resu) });

kvsrohit commented 11 months ago
decisionTable.execute_decision_table("EB", decision_table,payload, (err, resu)=> {
console.log("Rule result: ", err, resu);
});
kvsrohit commented 11 months ago

As pointed out by @davidsamlee callback function takes two arguments (err, results)