Hi, i am trying to read the value of an OptionSetValue using the code below, but it is not working and it's throwing the error :
Error of Plugin: System.InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Sdk.OptionSetValue' to type 'System.String'.
at Microsoft.Xrm.Sdk.Entity.GetAttributeValue[T(String attributeLogicalName).
Any ideas?
if (entity.Attributes.Contains("addresstypecode"))
{
var address_type = entity.GetAttributeValue("addresstypecode").Value.ToString();
QueryExpression query = new QueryExpression("customeraddress");
query.ColumnSet = new ColumnSet("addresstypecode");
query.Criteria.AddCondition("addresstypecode", ConditionOperator.Equal, address_type);
EntityCollection collection = service.RetrieveMultiple(query);