Setting a permanent filter on the Add Opportunity Product screen in the SalesLogix web client

I recently was asked to add a permanent filter on the add opportunity product screen to control what products were available to a user.  The requirements called for only certain products to be visible to some users while other products were available to other users, and still other products were available to all users.  This may sound complex but it is actually pretty easy, provided you know where to start. 

I will demonstrate an example where we have two user groups “Sales” and “Support”.  Let’s assume that our product catalog has been modified so that each product record contains a value of “Support”, “Sales”, or “Both” in the ProductGroup property. And we want to check to see if a user is in the “Support” team.  If they are we only want to show products with a ProductGroup = “Support” or “Both”.  If the user is not in the “Support” team, they should only see products marked as either “Sales” or “Both”.

The main thing is to know to get to modifying the SalesLogix web client for this functionality is that the add opportunity product is a custom smart part.

First, locate the AddOpportunityProduct SmartMart. Since this is a custom SmartPart, not a QuickForm, you won’t find this under the Opportunity entity itself, but instead in the Sage SalesLogix Portal in following location (we’ll just need the code-behind, or “cs” file for this, not the “ascx” file) Support FilesSmartPartsOpportunityAddOpportunityProduct.ascx.cs

Double-click that file to open it in the Application Architect. In the code, look for the method named GetProductList. If you examine that method you can see how it uses the selected on-screen filters to add conditional operators to the criteria. 

At the very end of that method, you’ll see the following two lines :

List<Product> ProductList = criteriaProduct.List<Product>() as List<Product>;
return ProductList;

These last two lines actually take the criteria list and returns the workable list that is used by the Add Opportunity Product’s tree control.

Right before these lines of code we can add code to:

  1. First, get the teams the current user is on.
  2. Based on the team, then set a global filter

To get the current team the user is on we can use code like is shown in this post:

string userType = “sales”; //Defaulting to sales
Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>();
Sage.SalesLogix.Security.User user = usersvc.GetUser();
System.Collections.Generic.IList<Sage.SalesLogix.Security.Owner> teamlist = Sage.SalesLogix.Security.Owner.GetTeamsByUser(user);
foreach (Sage.SalesLogix.Security.Owner team in teamlist)
    if (team.OwnerDescription.ToUpper() == “SUPPORT”) userType = “support”;          

Now the code shown above will get an instance of the current user and it’s owner collection.  Inside the collection it then loops through to see if the user is on a team called “Support”.  If they are it sets a variable called “userType” to “support”, otherwise it uses the default value set for the variable of “sales”.

Now that we have determined wether or not the user is on the support team, we can then add a global filter that is always applied, independent of the filters the user selects through the UI.

if userType == “support”
    SearchParameter enumCondition = SearchParameter.NotEqualTo;
           criteriaProduct.Add(GetExpression(expProduct, enumCondition, “ProductGroup”, “Sales”));
    SearchParameter enumCondition = SearchParameter.NotEqualTo;
          criteriaProduct.Add(GetExpression(expProduct, enumCondition, “ProductGroup”, “Support”));

Now in this code snippet I check to see if the userType variable has been set to “support” (this denotes the current user is on that team).  If this condition is met I want to apply a filter to the criteria list to exclude and Products where the ProductGroup property = “Sales”.  Conversely, if they are not in the support team then I want to exclude any products where the ProductGroup property = “Support”.  Using this code we also get the benefit that if the ProductGroup <> Sales or Support then both groups will still see it since we are only excluding those specific values from the other groups.

Be aware that in my example I am using the ProductGroup property which correlates to the PRODUCT.PRODUCTGROUP database field.  In the standard system, this field is not included in the Product entity model and would need to be for this code to function.


Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!