Showing results for 
Search instead for 
Do you mean 

Associating a picklist with a field

Copper Contributor
Posts: 119
Country: USA

Associating a picklist with a field

by TDavis on 11-20-2007 8:50 AM

Hope someone can help....

I can create a field using the sdk and I can create a picklist and add items to it but how do I associate the picklist I've created with the new field?

 Tom Davis

Copper Contributor
Posts: 119
Country: USA

Re: Associating a picklist with a field

by Vivek on 11-20-2007 9:25 AM

Hi Tom,

 I've tried to do this in the past and hit the very same wall. I don't believe the methodology has been exposed. I hope I am wrong on this and someone can let us both know!

Vivek Gargav

Copper Contributor
Posts: 119
Country: USA

Re: Associating a picklist with a field

 by rscherrer on 11-28-2007 10:10 AM


by modifying the  FieldDescriptorAttributeCollection(). see below.



         Public Shared Function AssignPicklistToField(ByVal sPicklistName As String, _
                                                     ByVal sFieledName As String, _
                                                     ByVal bLimitToList As Boolean, _
                                                     ByVal bMultiSelect As Boolean, _
                                                     ByVal bTypeAhead As Boolean, _
                                                     ByVal bShowDescription As Boolean) As Boolean
                Dim flds As Act.Framework.Database.FieldDescriptorCollection = _
                Dim fld As Act.Framework.Database.FieldDescriptor = flds.Item(sFieledName)

                Dim plprop As Act.Framework.Database.FieldProperty = _
                If fld.Attributes.Contains(plprop) Then
                    fld.Attributes(plprop) = Act.Framework.Database.PickListAttribute.None
                End If

                If Not sPicklistName Is Nothing Or Not sPicklistName.Equals(String.Empty) Then
                    Dim pklst As Act.Framework.PickLists.PickList = _
                    If ((Not pklst Is Nothing) AndAlso fld.CanBindTo(pklst.Type)) Then
                        fld.Attributes(plprop) = New Act.Framework.Database.PickListAttribute _
                            (pklst, bLimitToList, bMultiSelect, bTypeAhead, bShowDescription)
                    End If
                End If
                Return True
            Catch ex As Exception
                Return False
            End Try
        End Function

Reto Scherrer
Ambit AG