Tokens and extending rule support

i don't think I understand the creation/extension of rules correctly.

What I am trying to do is:

for an existing trigger/when (a forum reply is created), create a condition/if of:
Forum Reply: Author
with a custom token User: Number of Forum Replies
whose value is the result of a piece of code defined in my plugin.
and the existing action/then "award acheivement".

What I'm not getting is the magic to connect my ITokensRegistrar class to the rules engine condition/if IConfigurableRuleCondition. I've been following what's at community.telligent.com/.../registering-tokens-for-templates and community.telligent.com/.../extending-rule-support but I think I'm missing something fundamental to connect the custom code to the Forum Reply: Author "type". Any pointers?

  • If you want your custom token to appear alongside the out-of-the-box User tokens every time a User appears in the token list, you need to register it with the same DataTypeId as the rest of the user tokens. Usually for API entities, this id is either Apis.Get<...>().DataTypeId if available, or Apis.Get<...>().ContentTypeId. In this case it would be Apis.Get<IUsers>().ContentTypeId.

    The rest of the rule structure you described should already exist out-of-the-box. However, if you were to ever desire to create a custom rule action, you would just want to include in the Rule trigger's IEnumerable<Guid> ContextualDataTypeIds any custom DataTypeIds you used for related tokens.

  • Close! In concrete terms:

    why do I see my condition element again? Is it a function of my resolve function not being right, or some other place that isn't letting it know it's an int (and thus should trigger the 'greater than/less than/etc' list)?

  • Did you create your token as an ITokenizedTemplateDataTypeContainerToken? This requires you to specify ContextualDataTypeIds that signify what data types the ContainerToken "contains" - which extends the token chain in the condition. If you just want a simple number to be resolved from your token at rule run time, use a ITokenizedTemplatePrimitiveToken and specify PrimitiveType.Int.