1

Sitecore 9.2

I'm trying to create a rule and execute a script but I can't execute my code from the Script reference.

My objective is to show Form B instead of Form A when the script returns true.

Here's my rule:

enter image description here

Here's the content that I want to show when the condition is true:

enter image description here

Here's my script (I added the namespace and assembly)

enter image description here

And here's the code:

enter image description here

My instance and the project are already deployed, so what I'm doing wrong?

5
  • I think what you're building should be a WhenCondition, which is also the direction your code is taking. Have a look here: sitecore.stackexchange.com/questions/5168/… – Mark Cassidy Nov 11 '19 at 17:55
  • And then there's the usual; make sure you've installed a Sitecore XP (not just an XM). – Mark Cassidy Nov 11 '19 at 17:55
  • @MarkCassidy, I have Sitecore XP, also I have xdb.enabled and xdb.tracking.enabled – gonzdn Nov 11 '19 at 19:24
  • I made two sentences.... :P – Mark Cassidy Nov 11 '19 at 19:47
  • I suggest you checking HTML caching settings for your component and disable them if it is cached. I noticed a break change in Sitecore 9.2. If caching is enabled for the component and the same component is personalized, the personalization will not work any more. Before Sitecore 9.2 that worked perfectly. – i123fr3 Nov 28 '19 at 18:43
3

Could you please update your code as below:

public class Evaluatecanada<T> : StringOperatorCondition<T> where T : RuleContext
{        
    protected override bool Execute(T ruleContext)
    {            
            return true;           
    }
}

I have faced the same issue but in my code, I have inherited it with StringOperatorCondition instead of WhenCondition.

You can find more details here Custom Personalization Rules in Sitecore 9

1
  • thanks for your answer, but still I the script doesn't execute :( – gonzdn Nov 13 '19 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.