Hello Dmytro,
can you please advise a multivalue attribute can be properly addresses in a report?
I want to add a custom calculated column to the report, value of which is based on user multivalue attribute.
E.g. if attribute is:
A
B
C
to show B in calculated column.
Value references of multi-value attributes resolve only into the last value of the attributes. To iterate through all the values of a multi-value attribute, you need to bind to the object (e.g. using the $Context.GetADObject method) and use the GetEx method to get the property values. The script should be like the following:
$propertyName = "adm-CustomAttributeTextMultiValue1" # TODO: modify me
$valueToCheck = "B" # TODO: modify me
# Get AD object
$user = $Context.GetADObject()
# Get property value
try
{
$values = $user.GetEx($propertyName)
}
catch
{
$values = @()
}
# Set column value
if ($values -contains $valueToCheck)
{
$Context.Value = $valueToCheck
}
else
{
$Context.Value = $NULL
}
In the script:
- $propertyName – specifies the LDAP name of the multi-value attribute for check;
- $valueToCheck – specifies a value for search in the attribute specified for the $propertyName variable.
But when I do If ($Context.GetParameterValue("%adm-CustomAttributeTextMultiValue1%") -contains "B") - it always fails, since GetParameterValue returns always C.
The GetParameterValue method is used to get values of report parameters and requires a parameter name as its argument. It cannot be used to get values of object properties.
For your information, in scripts for generation of a report or report custom column value references resolve into values of corresponding properties of the user that is generating the report.