Hello Mike,
Thank you for clarifying. In this case, the approach will be totally different. You will need the following:
Business rule triggering Before creating a user
The rule will check the value of the custom integer attribute of the operation initiator. If the number equals two, the operation will be cancelled.
In the rule condition, use the below script. In the script, the $propertyName variable specifies the schema name of the attribute to check.
$propertyName = "adm-CustomAttributeInt1" # TODO: modify me
# Bind to operation initiator
$initiator = $Context.BindToObjectByDN("%adm-InitiatorDN%")
# Get integer attribute value
try
{
$value = $initiator.Get($propertyName)
}
catch
{
$Context.ConditionIsMet = $False
return
}
$Context.ConditionIsMet = $value -eq 2
Business rule triggering After creating a user
We recommend you to have a separate business rule that will trigger for all user creations and increment the integer attribute for all initiators. The rule will look like the following.
In the rule, use the below script. In the script, the $propertyName variable specifies the schema name of the attribute to update.
$propertyName = "adm-CustomAttributeInt1" # TODO: modify me
# Bind to operation initiator
$initiator = $Context.BindToObjectByDN("%adm-InitiatorDN%")
# Get integer attribute value
try
{
$value = $initiator.Get($propertyName)
}
catch
{
$value = 0
}
# Update initiator
$valueToSet = $value + 1
$initiator.Put($propertyName, $valueToSet)
$initiator.SetInfo()
Scheduled task
The scheduled task should be executed after hours (e.g. at midnight) and clear the integer attribute used in the workflow for all users.