You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, we have implement bpmn-js for our project and we are using bpmn-modeller to build flow xml which is used for AGI calling. The engine which we are using for bpmn flow execution during AGI call is bpmn-engine.
BPMN provides condition control component (also known as Exclusive Gateway), for which a string is saved in sequenceFlow tag which is executed only when the condition is true.
For example:
But now I want that instead of writing comparison string, I call a function for the same, which is already present in this.environment.services.
So, after implementing, XML generated is as follows:
async function compareDate1(ivrVar, variable, operator, value, dateFormat) {
console.log("comparing date");
const keys = variable.split('.');
// Use reduce to iterate over the keys and access the value dynamically
let date = keys.reduce((acc, key) => acc[key], ivrVar);
const formattedDate = DateUtil.format({dateString:date, sourceDateFormat:dateFormat, targetDateFormat:"YYYY-MM-DD"});
// Convert formattedDate to a Date object to compare
const formattedDateObj = new Date(formattedDate);
const currDateObj = eval(value);
// Compare the two Date objects using the operator
let result;
switch (operator) {
case '<=':
result = formattedDateObj <= currDateObj;
break;
case '>=':
result = formattedDateObj >= currDateObj;
break;
case '>':
result = formattedDateObj > currDateObj;
break;
case '<':
result = formattedDateObj < currDateObj;
break;
case '===':
result = formattedDateObj === currDateObj;
break;
case '!==':
result = formattedDateObj !== currDateObj;
break;
default:
result = false; // In case of an invalid operator
}
return result;
}
For the first sequence flow, it returns false, so ideally it should move the execution to second sequence flow and same function should be executed again to check the case, but after first sequence flow only the execution moves to the targetRef of first sequence flow.
Current scenario:
First sequence flow executes the function compareDate.
False is returned from compareDate as per use case.
Now the execution goes to targetRef of first sequence flow, despite of the function returning false.
Expected behaviour:
First sequence flow executes the function compareDate.
False is returned from compareDate as per use case.
So the execution should now go for second sequence flow.
If the function compareDate returns true now, then the flow should move to targetRef of second sequence flow.
Can someone please assist with this issue?
The text was updated successfully, but these errors were encountered:
Firstly there is no need for eval when using javascript condition:
<conditionExpressionxsi:type="tFormalExpression"language="javascript">next(null,this.environment.services.compareDate(this.environment.variables.ivrVar.payment.testingHeader.expiry, "<=", new Date(), "MMYY"));</conditionExpression>
Hi, we have implement bpmn-js for our project and we are using bpmn-modeller to build flow xml which is used for AGI calling. The engine which we are using for bpmn flow execution during AGI call is bpmn-engine.
BPMN provides condition control component (also known as Exclusive Gateway), for which a string is saved in sequenceFlow tag which is executed only when the condition is true.
For example:
which is working perfectly fine.
But now I want that instead of writing comparison string, I call a function for the same, which is already present in this.environment.services.
So, after implementing, XML generated is as follows:
And the function compareDate:
For the first sequence flow, it returns false, so ideally it should move the execution to second sequence flow and same function should be executed again to check the case, but after first sequence flow only the execution moves to the targetRef of first sequence flow.
Current scenario:
Expected behaviour:
If the function compareDate returns true now, then the flow should move to targetRef of second sequence flow.
Can someone please assist with this issue?
The text was updated successfully, but these errors were encountered: