Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Thursday, June 5, 2025 
 
slxdeveloper.com Community Forums  
   
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!
 Web Forums - SalesLogix Web Platform & Application Architect
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Platform & Application Architect | New ThreadView:  Search:  
 Author  Thread: SalesLogix Web 7.5.4 and Dynamic PreFilters in a Lookup
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
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! Yell


Thanks,


Nick

[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Oct 11 9:35 AM
fiogf49gjkf0d

Nick:


 


  I haven't done much on lookups lately, but I thought it was as simple as:


        lookupControl.LookupPreFilters.Clear();


 


Check this post by Mark Dykun


http://codesnap.wordpress.com/2011/07/06/lookup-prefilters/

[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
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...

[Reply][Quote]
Marcos Orfila
Posts: 40
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
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

[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
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);

[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
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


 


 

[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Dec 11 9:01 AM
fiogf49gjkf0d

Oh and clearing the httpcontext...cache doesnt work either as you have noticed!

[Reply][Quote]
Marcos Orfila
Posts: 40
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
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/


 

[Reply][Quote]
Marcos Orfila
Posts: 40
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Dec 11 11:15 AM
fiogf49gjkf0d

Thank you Nick! I did not see your comment. I was too busy testing my solution


Thanks everyone. This is a great community.

[Reply][Quote]
Mike LaSpina
Posts: 116
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
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 };

[Reply][Quote]
Michael Wolff
Posts: 4
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
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;


 


[Reply][Quote]
Mike LaSpina
Posts: 116
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
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.

[Reply][Quote]
Michael Wolff
Posts: 4
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
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;


 


[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Apr 12 5:17 AM
fiogf49gjkf0d

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..

[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Apr 12 5:20 AM
fiogf49gjkf0d

Quote:
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..

[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: SalesLogix Web 7.5.4 and Dynamic PreFilters in a LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Apr 14 3:33 PM

Has anyone tried this in 8.1 where the lookup is instantiated via Javascript? Thanks

[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 6/5/2025 2:45:24 AM