We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script repository

Validate properties against each other

February 23, 2021 Views: 1036

The script validates 2 properties against each other. For example, using the script, you can check whether a city and a country specified for a particular user can be used together. The script can be used in the If PowerShell script returns true condition of a business rule triggering Before updating/creating a user. The script returns True when values of the properties do not match.

Parameters:

  • $property1 - Specifies the LDAP name of the first property to check.
  • $property2 - Specifies the LDAP 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 proeprties do not match the mapping.
Edit Remove
PowerShell
$property1 = "c" # TODO: modify me
$property2 = "l" # TODO: modify me

$propertyMap = @{
    "US" = "Washington", "New York", "Boston";
    "FR" = "Paris", "Marseilles", "Lyon";
} # TODO: modify me: "property1Value" = "Property2Value", "Property2Value", "Property2Value"

# Get value of property 1
$value1 = $Context.GetModifiedPropertyValue($property1)

if ([System.String]::IsNullOrEmpty($value1))
{
    $Context.ConditionIsMet = $False # Property 1 is not specified
    return 
}

# Get department
$value2 = $Context.GetModifiedPropertyValue($property2)

# Check department
$Context.ConditionIsMet = $propertyMap[$value1] -notcontains $value2
Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers