Update 2019
Starting with version 2019.1, the If the object belongs to <Business Unit> condition is available in business rules, custom commands and scheduled tasks.
Original
Hello Joel,
The If <object> is a member of <Business Unit> condition is not present in Adaxes because there is basically no need for it. When you define the Activity Scope for a Business Rule or Scheduled Task, you can include or exclude a Business Unit, which is approximately the same as if you've put the If <object> is / is not a member of <Business Unit> condition in the rule or task. However, if you can't do without this condition, you can easily check whether an object is a mmber of a Business unit with the help of a PowerShell script. For example, the following script returns True if the target object on which a Business Rule, Custom Command or Scheduled Task is executed, is a member of a Business Unit named My Unit:
$businessUnitName = "My Unit" # TODO: modify me
$Context.ConditionIsMet = $False
# Search Business Units with the name specified
$businessUnitsPath = $Context.GetWellKnownContainerPath("BusinessUnits")
$searcher = $Context.BindToObject($businessUnitsPath)
$searcher.SearchFilter = "(&(objectCategory=adm-BusinessUnit)(name=$businessUnitName))"
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searcher.PageSize = 500
$searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"
try
{
$searchResult = $searcher.ExecuteSearch()
$units = $searchResult.FetchAll()
if ($units.Count -eq 0)
{
$Context.LogMessage("No Business Units with name '$businessUnitName' found.", "Warning")
return
}
foreach ($unitId in $units)
{
$unit = $Context.BindToObject($unitId.AdsPath)
if ($unit.IsMember($Context.TargetObject))
{
$Context.ConditionIsMet = $True
return
}
}
}
finally
{
$searchResult.Dispose()
}
The script must be used with the If PowerShell script returns true condition. For information on how to add and configure such a condition, see step 6 in the following tutorial: http://www.adaxes.com/tutorials_Simplif ... Script.htm.