You need to sign in to do that
Don't have an account?
Michael.Watkins
dependent picklist vb sample needed
anyone have a vb.net example for populating a dropdown list dynamically based on the controller selected value?
this seems like such a simple thing to expect from the API, but i have had no real success so far in converting the java or c# samples provided by the api documentation.
thanks in advance
this seems like such a simple thing to expect from the API, but i have had no real success so far in converting the java or c# samples provided by the api documentation.
thanks in advance
THis is not optimized but does show how to populate a drop down from the Case table using the picklist "Products_Supported__c".
Dim dsSalesforceCaseComments As New DataTable("MyDataTable")
dsSalesforceCaseComments.Columns.Add("ProductName", System.Type.GetType("System.String"))
Dim describeSObjectResults As apex.DescribeSObjectResult() = binding.describeSObjects(New String() {"case"})
For x As Integer = 0 To describeSObjectResults.Length - 1
Dim describeSObjectResult As apex.DescribeSObjectResult = describeSObjectResults(x)
' Retrieve fields from the results
Dim fields As apex.Field() = describeSObjectResult.fields
' Get the name of the object
Dim objectName As String = describeSObjectResult.name
' Get some flags
Dim isActivateable As Boolean = describeSObjectResult.activateable
' Many other values are accessible
If fields IsNot Nothing Then
For i As Integer = 0 To fields.Length - 1
' Iterate through the fields to get properties for each field
Dim field As apex.Field = fields(i)
Dim byteLength As Integer = field.byteLength
Dim digits As Integer = field.digits
Dim label As String = field.label
Dim length As Integer = field.length
Dim name As String = field.name
Dim picklistValues As apex.PicklistEntry() = field.picklistValues
Dim precision As Integer = field.precision
Dim referenceTos As String() = field.referenceTo
Dim scale As Integer = field.scale
Dim fieldType As apex.fieldType = field.type
Dim fieldIsCreateable As Boolean = field.createable
' Determine whether there are picklist values
If picklistValues IsNot Nothing AndAlso picklistValues(0) IsNot Nothing And name = "Products_Supported__c" Then
For j As Integer = 0 To picklistValues.Length - 1
If picklistValues(j).label IsNot Nothing Then
'add row in datatable with array data matching defined columns
dsSalesforceCaseComments.Rows.Add(picklistValues(j).label)
End If
Next
Exit For
End If
' Determine whether this field refers to another object
'If referenceTos IsNot Nothing AndAlso referenceTos(0) IsNot Nothing Then
' lblViewCasesMessages.Text += "<br>Field references the following objects:<br>"
' For j As Integer = 0 To referenceTos.Length - 1
' lblViewCasesMessages.Text += "<br> " + referenceTos(j)
' Next
'End If
Next
End If
Next
dsSalesforceCaseComments.DefaultView.Sort = "ProductName"
ddlProducts.DataSource = dsSalesforceCaseComments
ddlProducts.DataBind()
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
If Not picklistValues(iPickListIndex).validFor Is Nothing Then
oPickListEntry = New PicklistEntry
For Each oPickListEntry In picklistValues
' *******************************************************************************
' here is the issue:
' capture the item if its a viable picklist choice for the selected item in the controller
if [?some vb BitSet process using the VALIDFOR objects?] then
oDataRow = oDataSet.Tables(0).NewRow
oDataRow.Item(0) = picklistValues(iPickListIndex).label
oDataSet.Tables(0).Rows.Add(oDataRow)
end if
' *******************************************************************************
Next
End If
End If
Next
End If
thanks again for your help!