The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Posted: 17 Oct 11 3:57 AM
|
fiogf49gjkf0d Hi,
Hopefully someone can help before I lose all my hair...
I am trying to do something very rudimentary (I think!). I have a currency lookup that I wish, on certain occasions, to PreFilter to just three of the available currencies. I have the code to do this I believe thanks to a helpful post blog from Mr Galler. The problem I have is the PreFilters get cached until you log out, so they work the first time then when you want to change them no joy until you logout and back in again.
Does anyone have the exact code to remove this cache and reload my new PreFIlters, on the fly? I have seen a few forums on this, some more vague then others.
So far: InvalidateControlCache or similar can be used - cant see this method anywhere....
LookupFilterState something or other, remove and re-add. Trouble is where do you re-add, and what do you re-add it to?
I also heard in 7.5.4 there was a method introduced to clear the lookup cache, but again I cant find it anywhere obvious...
A lot of time spent so far on something that should be simple! 
Thanks,
Nick |
|
|
| |
|
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Posted: 17 Oct 11 9:39 AM
|
fiogf49gjkf0d Thanks for reply Raul - unfortunately while that code does work, it takes a full on logout and back in again for the Lookup Prefilters to be cleared.
If you set them up on a quickformload the first time anyone visits the page it works fine. But if you want to change the prefilters on a change event for example, it does not apply the prefilters until you logout (which forces a Lookup cache removal). I saw a post by Mark to remove the cache from the HTTPContext.Current... hoping that might do the trick but it doesn't appear to work... |
|
|
|
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Posted: 08 Dec 11 7:48 AM
|
fiogf49gjkf0d After trying with "lookupControl.LookupPreFilters.Clear();", I tried clearing the cache manually, but the Lookup still filters by its last prefilter.
Here's an example where I remove the cache for the "ContactId" Lookup of the Activity Details smartpart (SmartParts/Activity/ActivityDetails.ascx.cs):
string cacheKey = "ctl00_TabControl_element_ActivityDetails_element_view_ActivityDetails_ActivityDetails_ContactId"; System.Web.HttpContext.Current.Cache.Remove(cacheKey); If I move to another page inside SalesLogix and then go back to the Activity Details page (e.g. creating a new meeting), the prefilter is still active.
It seems that the prefilter is being cached somewhere else.
Regards,
Marcos
|
|
|
|
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Posted: 08 Dec 11 8:31 AM
|
fiogf49gjkf0d Mark Dykun coached me through this last July, the following has been in production at a Major customer since then with no hiccups:
The prefilters will work as long as as the operator was in the validation list. The following operators are allowed in dependency lookups. Note that the names are case sensitive when typing them in.
· Starting with
· Contains
· Equal to
· Not Equal to
· Greater than
· Greater than or Equal
· Less than
· Less than or Equal
with that in place the following code will work correctly in a Smartpart load action
dplArea.LookupPreFilters.Clear();
Sage.SalesLogix.HighLevelTypes.LookupPreFilter filter = new Sage.SalesLogix.HighLevelTypes.LookupPreFilter("Area", "Area 1"); filter.CondOperator = "Not Equal to"; dplArea.LookupPreFilters.Add(filter); |
|
|
|
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Posted: 08 Dec 11 9:00 AM
|
fiogf49gjkf0d Hi Marcos,
Prefilters.Clear() doesn't work no (until you log out). Its quite useless actually. I have managed to get it to work now and that is by invalidating the lookup cache. Thanks to Nic Galler for the pointer on this one. Here is the code I use to ensure I can clear and reset lookups dynamically:
Sage.Entity.Interfaces.IOpportunity opp = this.BindingSource.Current as Sage.Entity.Interfaces.IOpportunity; Object[] myObjArray = new Object[1]; myObjArray.SetValue(opp, 0); QFSLXLookup.LookupExclusions = myObjArray; QFSLXLookup.LookupPreFilters.Clear(); LookupPreFilter pf = new LookupPreFilter(); pf.CondOperator = "Equal To";
pf.PropertyName = "Description"; pf.FilterValue = "%' and Opportunity.XX in ('Val 1','Val 2') and Opportunity.ExchangeRateCode like '" + opp.ExchangeRateCode + ""; pf.PropertyType = "String"; QFSLXLookup.LookupPreFilters.Add(pf);
That also shows how to add in some more detail to a prefilter...
Setting a LookupExclusions value array causes the lookup to NOT cache anything. So you can set the prefilters as often as you need, onchange of another field, onload etc.
If you dont actually want it to exclude anything from the lookup results just make the array empy.
Thanks,
Nick
|
|
|
| |
|
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Posted: 08 Dec 11 10:54 AM
|
fiogf49gjkf0d Thank you RJ Samp.
I found another solution (before I read your comment), which was suggested by Nicolas Galler in his blog post [1]. To avoid the use of the cache by the lookup control, you must set the "LookupExclusions" property to some value (e.g. an empty array). The default value for the LookupExclusions property is null, which makes the lookup control use the cache and thus makes it impossible to change the prefilters on the fly.
Following my example for the Activity Details page, I added the following line to the "Page_PreRender" method of the "SmartParts\Activities\ActivityDetails.ascx.cs" file to set the LookupExclusions of the "ContactId" lookup control:
ContactId.LookupExclusions = new object[0];
Now the "ContactId.LookupPreFilters.Clear();" call effectively clears the prefilters of the ContactId lookup control.
Regards,
Marcos
[1] http://blog.nicocrm.com/2009/05/15/tips-tricks-of-the-web-client/
|
|
|
| |
|
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Posted: 08 Dec 11 3:40 PM
|
fiogf49gjkf0d Just ran into this myself last week and used Nicks' trick. Thhe following code worked better in my case. Note that I'm injecting HQL directly into the lookup though as we're doing some and/or logic. Having zero lookup exclusions was throwing an error, but adding in a blank exclusion worked for me.
lueOpportunity.LookupExclusions = new string[] { string.Empty }; |
|
|
|
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Posted: 25 Apr 12 3:04 PM
|
fiogf49gjkf0d I am having this same issue. I am trying to pre-filter in the Load Action of a form. I am trying to set the LookupExclusions property, but it does not seem to be accessible to me. It does not show up in the code-complete. Does anyone know why?
<p>form.lkAddress.LookupPreFilters.Clear();
Sage.SalesLogix.HighLevelTypes.LookupPreFilter lookupFilter = new Sage.SalesLogix.HighLevelTypes.LookupPreFilter();
lookupFilter.CondOperator = "Equal to";
lookupFilter.FilterValue ="'" + machine.Account.Id.ToString().Trim() + "'";// "A6UJ9A000EG6";
lookupFilter.LookupEntityName = "Sage.Entity.Interfaces.IAddress";
lookupFilter.PropertyName = "EntityId";
lookupFilter.PropertyType = "System.string";
form.lkAddress.LookupPreFilters.Add(lookupFilter);
form.lkAddress.InitializeLookup = true;
|
|
|
|
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Posted: 25 Apr 12 3:32 PM
|
fiogf49gjkf0d Since you're dealing with the form interface, you're probably also dealing with control interfaces. You may have to declare a lookup control and cast form.mkAddress to it and assign the LookupExlusions that way. |
|
|
|
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Posted: 25 Apr 12 4:10 PM
|
fiogf49gjkf0d Thanks, Mike. That's correct. Here's the code I used to get it working:
<p>Sage.SalesLogix.Web.Controls.Lookup.LookupControl l = new Sage.SalesLogix.Web.Controls.Lookup.LookupControl();
l = (Sage.SalesLogix.Web.Controls.Lookup.LookupControl) form.lkAddress.NativeControl;
l.LookupExclusions = new string[] { string.Empty };
l.LookupPreFilters.Clear();
Sage.SalesLogix.HighLevelTypes.LookupPreFilter lookupFilter = new Sage.SalesLogix.HighLevelTypes.LookupPreFilter();
lookupFilter.CondOperator = "Equal to";
lookupFilter.FilterValue ="'" + machine.Account.Id.ToString().Trim() + "'";// "A6UJ9A000EG6";
lookupFilter.LookupEntityName = "Sage.Entity.Interfaces.IAddress";
lookupFilter.PropertyName = "EntityId";
lookupFilter.PropertyType = "System.string";
l.LookupPreFilters.Add(lookupFilter);
l.InitializeLookup = true;
|
|
|
| |
|
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Posted: 26 Apr 12 5:20 AM
|
fiogf49gjkf0d Originally posted by Nick Hollis
TBH the simplest way would just be to use a C# Code Snippet instead of a Code Snippet...I never use Code Snippets so do not know if the lookupexclusions properrtty is exposed..
|
|
Oops sorry just saw that you got it working.. |
|
|
| |
|