Using Apex Conditions

  • Select Call Apex condition type.
  • Select the Class Name in the drop-down. If you don't see your class in the drop-down, use Filter option.
  • Enter Parameters in a JSON format.

NOTE: Your custom Apex Class should implement WR_BPM.WorkflowCallApexRuleInterface Interface.

If run method returns 'true' conditions will not be met and action won't be executed. If action type is 'Rule' error message will be displayed and further actions won't be executed in case action is a part of Global Actions Group.

With the above setup global action will be executed (or will display error message if action type is 'Rule')  if {$Variables.callType} = 'check A' AND {$Variables.A} is not blank or if {$Variables.callType} = 'check B' AND {$Variables.B} = 'BBB'. Otherwise action won't execute.

public with sharing class WR_ApexRulesExpample implements WR_BPM.WorkflowCallApexRuleInterface
{
    public static Boolean run(sObject context, WR_BPM__Flow_Instance_Cursor__c flowInstanceCursor, String parameters)
    {
        Map<String, Object> params = (!String.isBlank(parameters) ? (Map<String, Object>)JSON.deserializeUntyped(parameters) : new Map <String, Object>());
   
        if(params.get('callType') == 'check A') 
        {
            if(String.isBlank((String)params.get('A')))
                return true;
            else 
                return false;
        }
        else if(params.get('callType') == 'check B' && params.get('B') == 'BBB')
            return false;
       
        return true;
    }
}

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.