Showing results for 
Search instead for 
Do you mean 

Two Ways To Default A Value in A Picklist

by on ‎08-01-2011 06:01 AM

1 - Quick Proof of Concept

Add an C# snippet to an onload event

Entity = ICallReportContact

Field = Host123

    Sage.Entity.Interfaces.ICallReportContact callreportcontact = BindingSource.Current as Sage.Entity.Interfaces.ICallReportContact;

    if (callreportcontact.Host123 == "Red")


      callreportcontact.Host123 = "Red";




        callreportcontact.Host123 = "Blue";




2 – Production Approach

  1. You should default the values in the OnCreate event of the entity.  This will ensure that the values are set no matter where the entity is created from. 
  2. You retrieve the default picklist item value rather than hard coding a value, that way an Administrator can modify the system behavior at a later date by modifying the picklist definition rather than needing to change code (or edit a string resource) and then have to do a full build and deploy of the web site.
  3. If you want to use the default value of the picklist, you’ll need some code to do that.  The Sage.SalesLogix.Picklists class has the functions you need to do that:

public static string GetDefaultPicklistItemValue( string pkName)


                  Sage.Platform.RepositoryHelper<IPickListView> plh = Sage.Platform.EntityFactory.GetRepositoryHelper<IPickListView>();

                  Sage.Platform.Repository.ICriteria crit = plh.CreateCriteria();

                  crit.Add(plh.EF.Eq("PickListName", pkName));               

                  foreach (IPickListView pl in crit.List<IPickListView>())


                        if (pl.DefaultIndex >= 0)


                              foreach (IPickListItemView itm in pl.PickListItems)


                                    if (itm.OrderSeq == pl.DefaultIndex)

                                          return (itm.Text);




                  return (string.Empty);


Register Read Guidelines Request Partner or Employee Access

What's New in 8.1