paed01/bpmn-engine

ConditionExpression ignored

Closed this issue · 2 comments

I have a BPMN that contains the following:

...
<sequenceFlow id="flow4" sourceRef="logger2" targetRef="checkLogin" />
    <sequenceFlow id="flow5b" sourceRef="checkLogin" targetRef="validLogin">
        <conditionExpression xsi:type="tFormalExpression">\${environment.services.isTrue(environment.output.loginPage.isValidLogin)}</conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow5a" sourceRef="checkLogin" targetRef="invalidLogin">
        <conditionExpression xsi:type="tFormalExpression">\${environment.services.isFalse(environment.output.loginPage.isValidLogin)}</conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow6" sourceRef="validLogin" targetRef="end1" />
    <sequenceFlow id="flow7" sourceRef="invalidLogin" targetRef="end2" />

    <endEvent id="end1" />
    <endEvent id="end2" />

Basically, the isTrue and isFalse services just check the input to see if it is true or false. However, whatever the value, the engine always seems to take the first path. That is, in the example above it would go to validLogin. If you switch the order of the conditionExpression elements, it will go to invalidLogin, even with the same input as before.

You can run a simple example that I put in this repo. If you debug it, you'll see only the first service is called and it does return the correct value.

I've tried the two different notations: the formalExpression and the JavaScript version (with next(null,...)). I've even tried just putting true or false as value of the conditionExpression.

paed01 commented

is the escaped dollar \${ intended or is the source copied from a templated string? If you have copied the source from an xml then try removing the escape back slash. The current expression will be resolved to the string \true, and strings with length are truthy, ergo condition is true.

No idea where I got that from. I thought from the docs somewhere, but I can't find it anymore. Removing the backslash does solve it, thanks.