{Dynamics Portal :: Display multi-select option set field}

We got one issue in dynamics portal form. Multi-select option set field is the new feature in Dynamics 365. But this field is not supported in Dynamics portal. So we need to find a workaround for this.

In Dynamics 365, Multi-select options selected values are stored as semi-colon separated (;). So we decided to create one text field and update the field whenever the change is happen at the option-select field.

  1. Thought of using workflow to trigger on update of the field, unfortunately we are not able to access then multi-select option set  field in the Workflow designer. Looks like its an limitation as of now.
  2. Finally, decided to go with plugin. 

Next difficulty is we are not able to access the option set label like we do traditionally. Because option set field returns selected value as “OptionSetValueCollection“. So here is the code block which helps to achieve the result in the required format.

var attributeRequest = new RetrieveAttributeRequest { EntityLogicalName = "entityname", LogicalName = "fieldname", RetrieveAsIfPublished = true }; var attributeResponse = (RetrieveAttributeResponse)service.Execute(attributeRequest); var attributeMetadata = (EnumAttributeMetadata)attributeResponse.AttributeMetadata; var optionList = (from o in attributeMetadata.OptionSet.Options select new { Value = o.Value, Text = o.Label.UserLocalizedLabel.Label }).ToList(); string concatText = ""; var sOptList = (OptionSetValueCollection)inputEntity.Attributes["fieldname"]; foreach (var item in sOptList) { var text = optionList.Where(o => o.Value == item.Value) .Select(o => o.Text) .FirstOrDefault(); concatText = concatText + ";" + text; } string requiredFormat = concatText.Substring(1, concatText.Length - 1);

hope this re-usable code block helps to minimize your effort in this work.

As usual, I love to hear feedback.

Do let me know, if you need any help…

2 thoughts on “{Dynamics Portal :: Display multi-select option set field}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

If you need any help on Dynamics project and training, reach out to me. Do connect with me on LinkedIn and follow this blog to know more about Dynamics and its related stuff. Once again, Happy to connect with you all through blogging. Do you share your valuable feedback?
%d bloggers like this: