# Define the values for the multi-select picklist attribute
$optionSetValues = @(484800005, 484800001, 484800003)
# Create account data
$account = @{
"name" = "A Viansh" # Single Line Text
"Multiselection" = $optionSetValues # Multi-Select Option Set
}
# Update the account record
$accountRecord = Set-CrmRecord -conn $conn -EntityLogicalName account -Id accounId -Fields $account
----------------------------
# Define the values for the multi-select picklist attribute
$optionSetValue1 = New-CrmOptionSetValue -Value 484800005
$optionSetValue2 = New-CrmOptionSetValue -Value 484800001
$optionSetValue3 = New-CrmOptionSetValue -Value 484800003
# Create account data
$account = @{
"name" = "AViansh" # Single Line Text
"Multiselection" = @($optionSetValue1, $optionSetValue2, $optionSetValue3) # Multi-Select Option Set
}
# Update the account record
$accountRecord = Set-CrmRecord -conn $conn -EntityLogicalName account -Id accountId -Fields $account


Mithilesh TataRank #862 · 2.6K reputationPosted Mar 23, 2024, 2:18 AM EDT
To update a multi-select option set field in Dynamics 365 using PowerShell, you first need to retrieve the existing values of the record, modify the multi-select option set field, and then update the record with the new values. Here's how you can do it:
# Connect to Dynamics 365 (you need to define $conn first) # Define the ID of the account record you want to update $accountId = "Your_Account_Id_Goes_Here" # Retrieve the existing values of the multi-select option set field from the account record $existingOptions = Get-CrmRecord -conn $conn -EntityLogicalName account -Id $accountId -Fields "new_multiselectfield" # Define the values for the multi-select picklist attribute $optionSetValues = @(484800005, 484800001, 484800003) # Create an array to hold new option set values $newOptionSetValues = @() # Loop through the values and convert them to CRM option set values foreach ($value in $optionSetValues) { $optionSetValue = New-CrmOptionSetValue -Value $value $newOptionSetValues += $optionSetValue } # Combine existing options and new options $newOptions = $existingOptions + $newOptionSetValues # Create account data $account = @{ "new_multiselectfield" = $newOptions # Multi-Select Option Set } # Update the account record with the new multi-select option set values $accountRecord = Set-CrmRecord -conn $conn -EntityLogicalName account -Id $accountId -Fields $accountIn this script:
$connvariable properly with connection details.Get-CrmRecord.New-CrmOptionSetValue.Set-CrmRecord.Make sure to replace
"new_multiselectfield"with the actual schema name of your multi-select option set field in Dynamics 365. Also, replace"Your_Account_Id_Goes_Here"with the ID of the account record you want to update.Allam PurushothamRank #715 · 3.3K reputationPosted Mar 26, 2024, 7:07 AM EDT
While using your code also same issue
FaultException`1 - Update : Updating account : 265bcef3-5aeb-ee11-a203-000d3a3b5473 |=> Incorrect attribute value type System.Object[]
Incorrect attribute value type System.Object[] => Incorrect attribute value type System.Object[] => System.ArgumentException: Incorrect attribute
value type System.Object[]
Parameter name: MultiSelection[TerminalFailure] Failed to Execute Command - Update : RequestID=09d2c983-a780-4458-b806-23eb7bcc1e96 :
Updating account : 265bcef3-5aeb-ee11-a203-000d3a3b5473 duration=00:00:01.3538665 ExceptionMessage = Incorrect attribute value type System.Object[]
Incorrect attribute value type System.Object[] => Incorrect attribute value type System.Object[] => System.ArgumentException: Incorrect attribute
value type System.Object[]