Back in the LAN client, there was a way to add multiple conditions to a lookup control, as long as you knew how to manipulate the Lookup properties to your advantage.
The web client’s lookup control is of course a different animal that now uses an SData feed to perform the lookup based on conditions. There is a pre filter property of the lookup control but you are very limited there in picking single conditions.
There is a way of doing this though by manipulating the lookup control itself. You can do so on a load action of a quick form using a C# snippet. Lets look at how you could add multiple conditions. Again by using the various attributes of the lookup control we can construct a valid SData query that will allow multiple conditions.
Let’s say we are in an Opportunity and want to show a lookup (called lookupProduct) to all Opportunity Products that are active and in the current opportunity, or some other criteria. We can use the following code to accomplish this:
Sage.Entity.Interfaces.IOpportunity opp = this.GetParentEntity() as Sage.Entity.Interfaces.IOpportunity; if (opp != null) { string prods = string.Empty; foreach(Sage.Entity.Interfaces.IOpportunityProduct op in opp.Products) { prods += string.Format("\"{0}\",", op.Product.Id); } lookupProduct.SeedProperty = "(Status"; lookupProduct.SeedValue = "Active\" and Id in (" + prods + ")) or \"A\" eq \"B"; lookupProduct.OverrideSeedOnSearch = false; }
We look through and construct a quote enclosed string of the Opportunity Products in the Opportunity.
Then we set the SeedProperty of the control to “(Status”. We add the ( in front of the property to handle the or clause logic later.
Then we set the SeedValue to the rest of our conditions. We include a quote after our first value and before our last value, because when the SeedProperty and SeedValue are appended together an opening quote and closing quote are added automatically.
With these 2 attributes, when the lookup is rendered and used, a query condition is constructed that looks like:
(Status eq "Active" and Id in ("123","456","etc.")) or "A" eq "B"
Remember this is an SData query so this is the where clause in the SData query language.