Hello,
Thank you for clarifying. Find detailed instructions for creating the Business Rules below.
i. Creating the Business Rule triggering Before updating a user
- Launch Adaxes Administration Console.
- In the Console Tree, right-click your service node.
- In the context menu, navigate to New and click Business Rule.
- On step 2 of the Create Business Rule wizard, select the User object type.
- Select Before updating a user and click Next.
- Click Add an action.
- Select Run a program or PowerShell script.
- Paste the below script into the Script field. In the script:
- $emptyValue - Specifies a value that will be set for the custom attribute if currently Job Title is empty.
- $propertyName - Specifies the LDAP name of the custom attribute to store the current Job title.
$emptyValue = "empty" # TODO: modify me
$propertyName = "adm-CustomAttributeText1" # TODO: modify me
# Get current Job Title
try
{
$oldTitle = $Context.TargetObject.Get("title")
}
catch
{
$oldTitle = $emptyValue
}
# Set custom attribute value
$Context.TargetObject.Put($propertyName, $oldTitle)
$Context.TargetObject.SetInfo()
- Enter a short description and click OK.
- Right-click the action you created and then click Add Condition.
- Select If <property/> changed.
- Select If Job Title has changed and click OK.
- Click Next and finish creating the Business Rule.
ii. Creating the Business Rule triggering After updating a user
- Launch Adaxes Administration Console.
- In the Console Tree, right-click your service node.
- In the context menu, navigate to New and click Business Rule.
- On step 2 of the Create Business Rule wizard, select the User object type.
- Select After updating a user and click Next.
- Click Add an action.
- Select Run a program or PowerShell script.
- Paste the below script into the Script field. In the script:
- $emptyValue - Specifies a value that will be used in the email notification if the new Job Title is empty.
- $to - Specifies the email address of the notification recipient.
- $subject - Specifies the email notification subject.
- $bodyTemplate - Specifies a template for the email notification body. In the template, the {0} placeholder will be replaced with the new Job Title or the value specifies in the $emptyValue variable.
$emptyValue = "empty" # TODO: modify me
$to = "s.kabarukhin@softerra.com" # TODO: modify me
$subject = "Job title of user %fullname% changed" # TODO: modify me
$bodyTemplate = @"
Job title of user %fullname% changed:
Old value: %adm-CustomAttributeText1%
New value: {0}
"@ # TODO: modify me
# Get new Job Title
try
{
$newTitle = $Context.TargetObject.Get("title")
}
catch
{
$newTitle = $emptyValue
}
# Build mail message
$mailMessage = [System.String]::Format($bodyTemplate, $newTitle)
# Send mail
$Context.SendMail($to, $subject, $mailMessage, $NULL)
- Enter a short description and click OK.
- Right-click the action you created and then click Add New Action.
- Select Update the user and click Add.
- In the Property to modify drop-down, select the custom attribute that stores the old Job Title.
- Select Remove property and click OK twice.
- Right-click the action you created again and then click Add Condition.
- Select If <property/> changed.
- Select If Job Title has changed and click OK.
- Click Next and finish creating the Business Rule. You should have something like the following: