In a previous post I talked about working with the Sage.SalesLogix.Picklist assembly to get a specific instance of a picklist item. Today I wanted to show how to work with an entire picklist list:
The assembly offers a method to return an IList collection of all picklist items in a specific picklist. The syntax for this is something like this:
System.Collections.Generic.IList<Sage.SalesLogix.PickLists.PickList> items = Sage.SalesLogix.PickLists.PickList.GetPickListItemsByName(“AccountType”, true);
As you can see the method is called GetPickListItemsByName. The method has a couple of overloads. The first parameter is always the picklist name, passed as a string. The second optional parameter is whether to return the list sorted alphabetically, expressed as a Boolean value.
With the IList returned you can bind it directly to a control,like a list box like so:
System.Collections.Generic.IList<Sage.SalesLogix.PickLists.PickList> vendors = Sage.SalesLogix.PickLists.PickList.GetPickListItemsByName(“Vendor”, true);
cboVendor.DataSource = vendors;
cboVendor.DataBind();
Alternatively you can work with the collection to do something like so:
System.Collections.Generic.IList <Sage.SalesLogix.PickLists.PickList> statuses = Sage.SalesLogix.PickLists.PickList.GetPickListItemsByName(“Product Status”, true);
foreach (Sage.SalesLogix.PickLists.PickList status in statuses)
{
if(status.Text.ToUpper()!=”AVAILABLE”) //Do something
}



