Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
ilyas393
Creator
Creator

Custom Property - multiple values of the same custom property

Hello Experts,

I am using Qlik Cli in powershell to assign custom property values to users. The code seem to work fine, but I see numbers with the value that gets assigned to the custom property.

Here is the snapshot. Does it mean the same value is getting assigned multiple times (like 2787 and 6706) times?

ilyas393_1-1663791778712.png

here is the code if anyone wants to take a look - 

 

 

$CSVUsers = Get-Content D:\custom_files\updatecustomproperties\QS_User_App_Access.csv|ConvertFrom-Csv
Connect-Qlik -TrustAllCerts

#region update Missing Custom Property Values
##Update the Custom Property if a value is missing.
$UCP = $CSVUsers.Customproperty|Select -Unique
$UCPNames = $UCP|%{$($_ -split "=")[0]}|select -Unique
foreach($UCPName in $UCPNames){
    $Changes = $false
    $Values = $UCP|?{$_.StartsWith("$($UCPName)=")}|%{$($_ -split "=")[1]}
    $QSCustomProperty = Get-QlikCustomProperty -filter "Name eq '$($UCPName)'" -full
    $Values|%{
        if (!($_ -in $QSCustomProperty.choiceValues)){
            $QSCustomProperty.choiceValues += $_
            $Changes=$true
        }
    }
    if ($Changes -eq $true){
        $QSCustomProperty = Update-QlikCustomProperty -id $QSCustomProperty.id -choiceValues $QSCustomProperty.choiceValues
    }
}
#endregion update Missing Custom Property Values

#region update User object
foreach ($CSVUser in $CSVUsers){

    $QSUser = Get-QlikUser -filter "UserID eq '$($CSVUser.UserId)'" -full
    if ($null -eq $QSUser){Write-Warning "User with ID $($CSVUser.UserId) Doest Not Exist"}else{
    [string[]]$customProperties = ""

    <# #Include the next line to maintain existing properties, exclude it to only include value from CSV.#>

    [string[]]$customProperties = $($QSUser.customProperties|%{"$($_.definition.Name)=$($_.value)"})
    
    
    $customProperties += $CSVUser.Customproperty
    $QSUser | Update-QlikUser -customProperties $customProperties
    }
}
#endregion update User object

 

 

thanks

Labels (2)
0 Replies