The script checks whether the value of one property matches the value allowed for another property. For example, using the script, you can check whether a city and a country can be used together. The script should be executed in the If PowerShell script returns true condition in a business rule triggering Before updating an object. If the property values do not match, the script returns true.
Parameters:
- $firstPropertyName - Specifies the schema name of the first property to check.
- $secondPropertyName - Specifies the schema name of the second property to check.
- $propertyMap - Maps values of the first property with values of the second property. The script returns TRUE if values of the properties do not match the mapping.
PowerShell
$firstPropertyName = "c" # TODO: modify me
$secondPropertyName = "l" # TODO: modify me
$propertyMap = @{
"US" = "Washington", "New York", "Boston";
"FR" = "Paris", "Marseilles", "Lyon";
} # TODO: modify me
# Get first property value.
$value1 = $Context.GetModifiedPropertyValue($firstPropertyName)
if ([System.String]::IsNullOrEmpty($value1))
{
$Context.ConditionIsMet = $False
return
}
# Get second property value.
$value2 = $Context.GetModifiedPropertyValue($secondPropertyName)
# Check values
$Context.ConditionIsMet = $propertyMap[$value1] -notcontains $value2