Script trait - use function logic to return boolean
Hi,
The OOTB script trait allows us to write script while creating segmentation rules. This has to be boolean expression. When we add a Javascript function to script block like below.
(function (){
var myFirstVar = "Test";
var mySecondVar = "Test1"
if (orderType == "Test" && deviceSKU == "Test1"){
return true;
}
})();
The segmentation editor shows the green highlighted background that segment is resolved. But when we access the main page in which teaser component is referring to a campaign linked to above segment with Javascript function, the segment is not getting resolved. If we add just boolean expression, the segment resolves fine in main page.
Is it possible to write Javascript function inside Script trait (so that we can perform more logic)? If so is there a correct way to do this so that main page resolves the segment.
Regards,
Sandeep