You need to sign in to do that
Don't have an account?
ChrisGountanis
Getting Picklist Data for .NET Combobox
How do you run an API call to get picklist data to fill a dropdown in .NET VB would be the easiest for me. What I am trying to do is get a list of case origins which is a picklist object to fill a drop down in my external API based application. I am reading, creating new and updating records but for some reason this is not easy for me to figure out.
'aspx.vb code behind
...
' populate type
Dim oCase As New sfCase
lstType.DataTextField = "ID"
lstType.DataValueField = "PickListValue"
lstType.DataSource = oCase.GetCaseType
lstType.DataBind()
oListItem = New ListItem
oListItem.Text = "--none--"
oListItem.Value = ""
lstType.Items.Insert(0, oListItem)
Public Function GetCaseType() As DataSet
Dim oSelfServiceUser As SelfServiceUser = System.Web.HttpContext.Current.Session("SalesForceSelfServiceUserData")
Dim oProxy As SforceService = sfUtilities.GetProxy()
Dim oDataSet As New DataSet
Dim oCase As New sfCase
Dim oResults As sforce.DescribeSObjectResult()
oResults = oProxy.describeSObjects(New String() {"Case"})
Dim oTable As New System.Data.DataTable
oTable.Columns.Add("ID")
oTable.Columns.Add("PickListValue")
oDataSet.Tables.Add(oTable)
For iIndex As Integer = 0 To oResults.Length - 1
Dim describeSObjectResult As sforce.DescribeSObjectResult = oResults(iIndex)
Dim oFields As sforce.Field() = describeSObjectResult.fields
If Not oFields Is Nothing Then
For iFieldIndex As Integer = 0 To oFields.Length - 1
Dim oField As sforce.Field = oFields(iFieldIndex)
Dim oName As String = oField.name
Dim picklistValues As sforce.PicklistEntry() = oField.picklistValues
Dim fieldType As sforce.fieldType = oField.type
If LCase(oName) = "type" Then
If (Not picklistValues Is Nothing AndAlso Not picklistValues(0) Is Nothing) Then
For iPickListIndex As Integer = 0 To picklistValues.Length - 1
If Not picklistValues(iPickListIndex).label Is Nothing Then
Dim oDataRow As DataRow = oDataSet.Tables(0).NewRow
oDataRow.Item(0) = picklistValues(iPickListIndex).label
oDataRow.Item(1) = picklistValues(iPickListIndex).label
oDataSet.Tables(0).Rows.Add(oDataRow)
End If
Next
End If
End If
Next
End If
Next
Return oDataSet
End Function