IAdmBusinessRuleConditionedActions2

The IAdmBusinessRuleConditionedActions2 interface extends the IAdmBusinessRuleConditionedActions interface with the possibility to add Else and Else If blocks.

Inheritance: IAdmBusinessRuleConditionedActions

Properties

  • Property

  • Description

  • ElseIfConditionedActions

  • Gets a collection of Else If blocks specified for the set of actions and conditions.

  • ElseActions

  • Gets a collection of actions specified for the Else block of the set of actions and conditions.

Details

ElseIfConditionedActions

Gets a collection of Else If blocks specified for the set of actions and conditions. Each item in the collection is a set of actions and conditions. Each set is represented by the IAdmBusinessRuleConditionedActions interface.

Examples

The following code sample adds the Else If block to the first set of actions and conditions in a business rule.

PowerShell
# The $rule variable represents a business rule

# Get first set of actions and conditions
$actionsAndConditions = $rule.ConditionedActions.GetObject(0)

# Create 'Else If' block
$elseIf = $actionsAndConditions.ElseIfConditionedActions.Create()
$elseIf.ConditionsLogicalOperation = "ADM_LOGICALOPERATION_AND"
$elseIf.SetInfo()

# Create 'Delete the object' action
$action = $elseIf.Actions.CreateEx("adm-DeleteObjectAction")
$action.ExecutionOptions = "ADM_ACTIONEXECUTIONOPTIONS_SYNC"
$deleteAction = $action.GetAction()
$deleteAction.DeleteSubtree = $true
$action.SetAction($deleteAction)
$action.SetInfo()

# Add the action to the 'Else If' block
$elseIf.Actions.Add($action)

# Create 'If account is disabled' condition
$condition = $elseIf.Conditions.CreateEx("adm-AccountStatusCondition")
$enabledCondition = $condition.GetCondition()
$enabledCondition.AccountStatus = "ADM_ACCOUNTSTATUS_DISABLED"
$condition.SetCondition($enabledCondition)
$condition.SetInfo()

# Add the condition to the 'Else If' block
$elseIf.Conditions.Add($condition)

# Add the 'Else If' block to the set
$actionsAndConditions.ElseIfConditionedActions.Add($elseIf)
C#
// The rule variable represents a business rule 

// Get first set of actions and conditions 
IAdmBusinessRuleConditionedActions2 actionsAndConditions = 
    (IAdmBusinessRuleConditionedActions2)rule.ConditionedActions.GetObject(0);

// Create 'Else If' block
IAdmBusinessRuleConditionedActions elseIf = 
    (IAdmBusinessRuleConditionedActions)actionsAndConditions.ElseIfConditionedActions.Create();
elseIf.ConditionsLogicalOperation = ADM_LOGICALOPERATION_ENUM.ADM_LOGICALOPERATION_AND;
elseIf.SetInfo();

//  Create 'Delete the object' action
IAdmBusinessRuleAction action =
    (IAdmBusinessRuleAction)elseIf.Actions.CreateEx(
    "adm-DeleteObjectAction");
action.ExecutionOptions = ADM_ACTIONEXECUTIONOPTIONS_ENUM.ADM_ACTIONEXECUTIONOPTIONS_SYNC;
IAdmDeleteObjectAction deleteAction = (IAdmDeleteObjectAction)action.GetAction();
deleteAction.DeleteSubtree = true;
action.SetAction(deleteAction);
action.SetInfo();

// Add the action to the 'Else If' block
elseIf.Actions.Add(action);

// Create 'If account is disabled' condition
IAdmBusinessRuleCondition condition = 
    (IAdmBusinessRuleCondition)elseIf.Conditions.CreateEx("adm-AccountStatusCondition");
IAdmAccountStatusCondition enabledCondition = 
    (IAdmAccountStatusCondition)condition.GetCondition();
enabledCondition.AccountStatus =
    ADM_ACCOUNTSTATUS_ENUM.ADM_ACCOUNTSTATUS_DISABLED;
condition.SetCondition(enabledCondition);
condition.SetInfo();

// Add the condition to the 'Else If' block
elseIf.Conditions.Add(condition);

// Add the 'Else If' block to the set
actionsAndConditions.ElseIfConditionedActions.Add(elseIf);

ElseActions

Gets a collection of actions specified for the Else block of the set of actions and conditions. Each action in the collection is represented by the IAdmBusinessRuleAction interface.

Examples

The following code sample adds the Else block to the first set of actions and conditions in a business rule.

PowerShell
# The $rule variable represents a business rule
                    
# Get the first set of actions and conditions
$actionsAndConditions = $rule.ConditionedActions.GetObject(0)

# Create 'Delete the object' action
$action = $actionsAndConditions.ElseActions.CreateEx("adm-DeleteObjectAction")
$action.ExecutionOptions = "ADM_ACTIONEXECUTIONOPTIONS_SYNC"
$deleteAction = $action.GetAction()
$deleteAction.DeleteSubtree = $true
$action.SetAction($deleteAction)
$action.SetInfo()

# Add the action to the 'Else' block
$actionsAndConditions.ElseActions.Add($action)
C#
// The rule variable represents a business rule 

// Get first set of actions and conditions 
IAdmBusinessRuleConditionedActions2 actionsAndConditions = 
    (IAdmBusinessRuleConditionedActions2)rule.ConditionedActions.GetObject(0);

//  Create 'Delete the object' action
IAdmBusinessRuleAction action = 
    (IAdmBusinessRuleAction)actionsAndConditions.ElseActions.CreateEx(
    "adm-DeleteObjectAction");
action.ExecutionOptions = ADM_ACTIONEXECUTIONOPTIONS_ENUM.ADM_ACTIONEXECUTIONOPTIONS_SYNC;
IAdmDeleteObjectAction deleteAction = (IAdmDeleteObjectAction)action.GetAction();
deleteAction.DeleteSubtree = true;
action.SetAction(deleteAction);
action.SetInfo();

// Add the action to the 'Else' block
actionsAndConditions.ElseActions.Add(action);

Requirements

Minimum required version: 2018.1

See also