0

I am trying to implement a custom rule in Sitecore 9.1

Thankfully it is working fine.

I want to put a condition that the user is able to provide an integer value. Please advise on that.

1

You can have a look at the Day of Month rule.

It's a built-in rule in Sitecore (/sitecore/system/Settings/Rules/Definitions/Elements/Date/Day of Month)

Its Text field says:

when the current day of the month [operatorid,Operator,,compares to] [DayNumber,Integer,,number]

The [DayNumber,Integer,,number] part is for user input.

It means:

  • DayNumber - it's the property in the condition class to which the value will be assigned
  • Integer - it's the name of the macro - that's what you're asking for. Macros are stored under /sitecore/system/Settings/Rules/Definitions/Macros node. Integer macro will allow only numbers.
  • number it's the placeholder text in the condition when the value is not entered yet.

You can do similar rule on your own and use Integer macro for your values.

Just use something like

when whatever my condition is [operatorid,Operator,,compares to] [value,Integer,,number]

And if you want to use Decimal macro instead of Integer, you can read my blog post Sitecore Rules Engine - decimal macro.

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.