04-30-2012 01:02 PM
I have managed to set the default picklist value via the Admistrator --> Picklist option, and the default is highlighted if you select the picklist control.
However my user do not want to have to click on the picklist control. If a default is set they would like to see it visible in the field, and only click the control if a change is required.
I need it for the Insert Opportunity Screen.
I have found several pieces of code (one from this forum) that should return the default value, but I can't seem to get it to work.
I'm not sure if I'm putting the code in the right Event.
Does anyone have any clear instruction on how to achieve this.
Thank you
Sarah
Solved! Go to Solution.
04-30-2012 01:19 PM
05-01-2012 05:27 AM
Thank you Raul
I have been using this section of code with no luck.
I think it might be to do with where I'm placing the code.
I've been placing it in the Primary Event for the Opportunity. Hoping that it would be pulled through to the Insert Opportunity Screen.
Any other suggestions, would be welcome.
Thanks
Sarah
05-03-2012 05:07 PM
First, you need to make a reference to Sage.SalesLogix.PickLists.dll in your business rule:
Now, you can use the following code to set a field to whatever the default picklist item is (we put this code in the OnCreate Event):
account.Type = GetDefaultPicklistItemValue("Account Type");
...
public static string GetDefaultPicklistItemValue( string pkName)
{
string sItem = string.Empty;
try
{
Sage.SalesLogix.PickLists.PickList pl = Sage.SalesLogix.PickLists.PickList.GetDefaultItemByName(pkName);
if (pl != null)
sItem = pl.Text;
}
catch (Exception e) {}
return(sItem);
}