I am struggling to get the text value from the option set. This is an ASP.NET MVC project I am working on. The view returns the value of the option set but I want to display the text.
Public Shared Function RetriveRecords() As List(Of AccountEntityModels)
Using service As OrganizationService = New OrganizationService("MyConnectionString")
Dim query As QueryExpression = New QueryExpression With {
.EntityName = "account",
.ColumnSet = New ColumnSet("new_licencestatus")
}
Dim info As List(Of AccountEntityModels) = New List(Of AccountEntityModels)()
Dim accountRecord As EntityCollection = service.RetrieveMultiple(query)
If accountRecord IsNot Nothing AndAlso accountRecord.Entities.Count > 0 Then
Dim accountModel As AccountEntityModels
For i As Integer = 0 To accountRecord.Entities.Count - 1
accountModel = New AccountEntityModels()
If accountRecord(i).Contains("new_licencestatus") AndAlso accountRecord(i)("new_licencestatus") IsNot Nothing Then accountModel.LicenceStatusValue = (CType(accountRecord(i)("new_licencestatus"), OptionSetValue)).Value.ToString
info.Add(accountModel)
Next
End If
Return info
End Using
End Function
AccountEntityModels
:
Public Property LicenceStatus As OptionSetValue
Public Property LicenceStatusValue As String