Script trait - use function logic to return boolean | Community
Skip to main content
Level 4
Jun 2, 2017 3:14 AM UTC
Solved

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
sandeepk7656774Accepted solution
Level 4
Jun 16, 2017 4:36 AM UTC

Removing colon (;) at the end of function works. Following works

(function (){ 

  var myFirstVar = "Test"; 

  var mySecondVar = "Test1" 

  if (orderType == "Test" && deviceSKU == "Test1"){ 

       return true; 

  } 

})()

Thanks,

Sandeep

3 replies

sandeepk7656774AuthorAccepted solution
Level 4
Jun 16, 2017 4:36 AM UTC

Removing colon (;) at the end of function works. Following works

(function (){ 

  var myFirstVar = "Test"; 

  var mySecondVar = "Test1" 

  if (orderType == "Test" && deviceSKU == "Test1"){ 

       return true; 

  } 

})()

Thanks,

Sandeep

Translate
Level 4
Jun 9, 2017 7:45 PM UTC

This is for Target engine in AEM

Translate
kautuk_sahni
Employee
Jun 8, 2017 7:20 AM UTC

Which product are your talking here? Adobe Target or Target engine in AEM?

Translate
Kautuk Sahni