Search code examples
alfrescoalfresco-shareevaluator

alfresco evaluators, is it possible to chain with OR condition?


My question is simple, is it possible to have multiple evaluators chained with OR condition on an action?

For example I'd like to have an action defined with some evaluators, but instead of having them chained in AND condition, I would like the final result would be true if eval1 OR activeWorkflows are true.

<action id="mark-as-custom" type="javascript" label="actions.mark-as-custom" icon="custom">
    <param name="function">onActionFormDialog</param>
    <param name="itemKind">action</param>
    <param name="itemId">markDocumentAsCustom</param>
    <param name="destination">{node.nodeRef}</param>
    <param name="mode">create</param>
    <param name="successMessage">actions.mark-as-custom.success</param>
    <param name="failureMessage">actions.mark-as-custom.failure</param>
    <permissions>
        <permission allow="true">Write</permission>
    </permissions>
    <evaluator>evaluator.doclib.action.IsMySite</evaluator>
    <evaluator negate="true">evaluator.doclib.document.eval1</evaluator>
    <evaluator negate="true">evaluator.doclib.indicator.activeWorkflows</evaluator>
    <evaluator negate="true">evaluator.doclib.action.isLocked</evaluator>
</action>

I know I can write a new java evaluator which can combine the single results with any wanted condition, but I wold like to know if there is a way to obtain that only trough xml configuration.

Thanks


Solution

  • Have you looked at the chainedMatchOne and chainedMatchAll evaluators? The chainedMatchAll would AND all of your evaluators together whereas the chainedMatchOne would OR them. Here's the doc on the out-of-the-box evaluators: https://docs.alfresco.com/5.2/concepts/doclib-predefined-evaluators-reference.html

    You can grep the source for examples of ChainedMatchOne to see how it works. Basically you'll just define a new evaluator in XML that specifies ChainedMatchOne as its parent, then you'll list the evaluators you want to be part of the evaluation.