In the Saleslogix 8.1 web client the dependency lookup still has a problem with the OnChange event. This problem has been around a long time, as a first reported on this back in 2010!!!. Essentially what happens is when the OnChange event occurs, the dependency lookup has yet to set the bound entity properties to the values selected in the dependency lookup. The entity binding only occurs after the completion of the full postback.
You have two work arounds for this.
1) Place you “OnChange” code for the Dependency Lookup on the Quick Form’s Page Load event with the On Repaint property turned on. This is lame as it runs for every postback, not just when the Dependency Lookup Control changes.
2) Don’t rely on the bound entity, but look at the control itself to get the values entered. Let’s look at that second approach:
To handle the OnChange event, what you need to do is to look at the dependency lookup control’s composite controls to find the textbox containing the result. You can then get the value and then manually set the entity model directly.
Here is a sample C# snippet you could add to the Ticket ACI dependency lookup control. This code only deals with Area, but you could expand for Category and Issue Too.
Sage.Entity.Interfaces.ITicket t = this.BindingSource.Current as Sage.Entity.Interfaces.ITicket;
//There is a bug with the dependency lookups where the onchange event runs before the entity binding occurs.
//The entity binding occurs but only on page postback
//As a result, we have to check the control to see what was selected, rather than the entity.
//Then set the entity property directly so our business rule works….
string area = string.Empty;
foreach (Control c in dplArea.Controls)
{
//Find Area return
if (c.ClientID.EndsWith(“_dplArea_Area_Text”))
{
area = ((TextBox)c).Text;
}
}
if (!string.IsNullOrEmpty(area)) t.Area = area;