Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

QuerybyAttribute option set values

$
0
0

I have been trying to get the values of optionsets but get the an error  Unable to cast object of type 'Microsoft.Xrm.Sdk.OptionSetValue' to type 'System.String'.

I have checked that the record exists ( in raw sql ) and that both optionset names are correct and in the correct case

                    Dim ReturnedSoftware As String = String.Empty
                    Dim ReturnedLicenceStatus As String = String.Empty
                    Dim AccountList As New QueryByAttribute("account")
                    AccountList.ColumnSet = New ColumnSet("new_service", "new_licencestatus")
                    AccountList.Attributes.AddRange("accountid")
                    AccountList.Values.AddRange(LicenceID)
                    Dim ReturnedAccountList As EntityCollection = service.RetrieveMultiple(AccountList)
                    For Each ReturnedAccount As Entity In ReturnedAccountList.Entities

                        If ReturnedAccount.Attributes.ContainsKey("new_service") Then
                            ReturnedSoftware = DirectCast(ReturnedAccount.Attributes("new_service"), String)
                        End If

                        If ReturnedAccount.Attributes.ContainsKey("new_licencestatus") Then
                            ReturnedLicenceStatus = DirectCast(ReturnedAccount.Attributes("new_licencestatus"), String)
                        End If
                        Exit For
                    Next


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>