Skip to content

Create multiselect option set references #486

Description

@EdCallahan

It would be nice to have New-CrmOptionSetValue be extended to handle multiselect option sets, which are setup in D365 to allow multiple options to be selected in the same record/field. Or to have a new function like "New-CrmOptionSetValues".

Currently, even when assigning only one value, the following will fail if the option set is configured to be multiselect:

$fields = @{ 'fieldname' = $(New-CrmOptionSetValue -Value 'fieldvalue') }
New-CrmRecord -conn $CrmClient -EntityLogicalName Entity -Fields $fields

I have this workaround, but handling it within a function call would be nice:

$optionSets = @(New-CrmOptionSetValue -Value 'fieldvalue')
$optionSetCollection = New-Object -TypeName "Microsoft.Xrm.Sdk.OptionSetValueCollection"
$null = $optionSetCollection.AddRange($optionSets)

$fields = @{ 'fieldname' = $optionSetCollection }
New-CrmRecord -conn $CrmClient -EntityLogicalName Entity -Fields $fields

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions