I am seeing different error when I compare both null and undefined. I have set a variable in context.
context.setVariable("isValidRequest",valid);// Here we are setting value as undefined.
EX:
<step>
<Condition>isValidRequest ! = null</Condition>
<Name>AssignMessage</Name>
</step>
It should not be executed. But it is executing. When we tested same comparison in java script policy we are getting the proper response
using null or undefined from scripts can be tricky, for eg, the values are serialized when its assigned to a variable, for eg, the value for valid could be something like 'org.mozilla.javascript.Undefined@260dac34'
Can you use a boolean instead? for eg,initialize valid with boolean
var valid= false;
..
context.setVariable("isValidaRequest",valid)
---
In your policy condition, you can use
<Condition>isValidRequest is true</Condition>
Thanks,
Some suggestions:
Snippet in a JSC that does some decoding of variables and makes sure to assign a good value:
var product.id = context.getVariable("product.id"); if (!product.id) product.id = ""; else product.id = decodeURIComponent(product.id); context.setVariable("product.id", product.id);
Subsequent flow steps implement a condition as follows:
<Step> <Name>buildRequestByID</Name> <Condition>(product.id != "")</Condition> </Step> <Step> <Name>buildRequestAll</Name> <Condition>(product.id == "")</Condition> </Step>