back to top

Creating Modules for SalesLogix Web and Hiding Toolbar Items at Runtime

Creating modules for SalesLogix Web is something that is likely something that is often overlooked or not used because they are assumed to be too complex or are just not understood. A module is an assembly that you’ve added to a page or the portal that adds functionality to the page. The great thing about a module is that you can change things about the page without needing to resort to doing something like modifying the deployed pages or SmartParts. This article will look at how to create a module to conditionally hide a menu item at runtime.

Note: In this article I will be creating a module that removes the “Import Leads” menu for users that are not on the Midwest team.

To create a module, you simply just need to create a new Class Library project in Visual Studio and reference some of the Sage DLLs. The main ones you’ll likely need referenced are:

  • Sage.Platform.dll
  • Sage.Platform.Application.dll
  • Microsoft.Practices.ObjectBuilder.dll

There will be other DLLs that you’ll likely need to reference as well depending on what exactly you’re doing in the module. The sample module in this post does include many others. The main thing is that your class in the DLL will need to implement the IModule interface from Sage.Platform.Application.dll.

When you implement the IModule interface, there are two things you must implement. The void Load method and a ModuleWorkItem get property returning a WorkItem. The shell of your module will look something like this:

namespace FX.Modules
{
public class LeadMenuModule : Sage.Platform.Application.IModule
{
public void Load()
{
// implement load code here
}
public WorkItem ModuleWorkItem
{
get { return null; }
}
}
}

Now we’ll need to add the code into our Load to do the work of checking to see the teams the user is on, and if not on the Midwest team to remove the menu item. However, in order to do that, we’ll need to access some of the available services for things like getting the parent WorkItem, using the UserService to get the current user, and so forth. We can easily get the references through dependency injection by adding the following to our class:

using Sage.Platform.Application;
using Sage.Platform.Security;
//...

private UIWorkItem _parentWorkItem;
[ServiceDependency(Type=typeof(WorkItem))]
public UIWorkItem ParentWorkItem
{
get { return _parentWorkItem; }
set { _parentWorkItem = value; }
}

private IUserService _userService;
[ServiceDependency]
public IUserService UserService
{
set { _userService = value; }
get { return _userService; }
}

Having those dependencies will make the work easy from here on out. One of the things we’ll need is to determine if the user is on a certain team or not as well. We can reference one of my earlier posts to determine that (See Determining if a User is a Member of a Team in SalesLogix Web).

Removing the Menu Item at Runtime

Before we look at the code altogether, let’s take a look at how to remove the menu item at runtime. It is easy enough to do now that we’ll have a reference to the page Work Item.

using Sage.Platform.WebPortal.Workspaces;
using Sage.Platform.WebPortal.Services;
using Sage.Platform.WebPortal.SmartParts;
//...

// Get the ToolbarWorkspace
ToolbarWorkspace toolbar = _parentWorkItem.Workspaces["ToolBar"] as ToolbarWorkspace;

// Get the MenuService for the ToolbarWorkspace
IMenuService menusvc = toolbar.WorkItem.Services.Get<IMenuService>();

// Find the "Tools" menu by it's ID
NavItemCollection navcol = menusvc.FindMenu("mnuTools") as NavItemCollection;
if (navcol != null)
{
// Remove the "Import Leads" menu by using it's ID
navcol.RemoveItem("tools_ImportLeads");
}

One thing to note is that if you look at a deployed page, such as the Account.aspx.cs file, you’ll see that in the Page_Load, the menu’s are constructed *before* the modules are loaded. So, when our module is added to the page, the menus will be loaded and ready for us.

Now, let’s see the complete code for the module:

using System;
using System.Collections.Generic;
using Sage.Platform.Application;
using Sage.Platform.Application.UI;
using Sage.Platform.WebPortal.Services;
using Sage.Platform.WebPortal.Workspaces;
using Sage.Platform.WebPortal.SmartParts;
using Sage.Platform.Security;
using Sage.SalesLogix.Security;

namespace FX.Modules
{
public class LeadMenuModule : Sage.Platform.Application.IModule
{
public void Load()
{
User user = (_userService as SLXUserService).GetUser();
if (user.Id.ToLower().Trim()=="admin") return;
if (!IsOnTeam("Midwest", user))
{
ToolbarWorkspace toolbar = _parentWorkItem.Workspaces["ToolBar"] as ToolbarWorkspace;
IMenuService menusvc = toolbar.WorkItem.Services.Get<IMenuService>();
NavItemCollection navcol = menusvc.FindMenu("mnuTools") as NavItemCollection;
if (navcol != null)
{
navcol.RemoveItem("tools_ImportLeads");
}
}
}
public bool IsOnTeam(string teamname, User user)
{
bool res = false;
IList<Owner> teams = Owner.GetTeamsByUser(user);
foreach (Owner team in teams)
{
if (team.OwnerDescription.ToLower().Equals(teamname.ToLower()))
{
res = true;
break;
}
}
return res;
}
public WorkItem ModuleWorkItem
{
get { return null; }
}
private UIWorkItem _parentWorkItem;
[ServiceDependency(Type=typeof(WorkItem))]
public UIWorkItem ParentWorkItem
{
get { return _parentWorkItem; }
set { _parentWorkItem = value; }
}
private IUserService _userService;
[ServiceDependency]
public IUserService UserService
{
set { _userService = value; }
get { return _userService; }
}
}
}

Not too bad. It made fairly easy work to get the job done. Now we just add this assembly into the “bin” folder in the Support Files for the portal and then add the module in to the “Modules” tabs of the portal itself (not to a specific page) and the code will apply throughout the entire portal. On any page the user visits, the code will ensure the Import Leads menu item is removed.

Note, we could make this even more generic if we wanted to. Let’s say we didn’t want to hard-code the team name, or the menu item ID. We could simple add some properties to the class like this:

public TeamName { get; set; }
public MenuItemID { get; set; }

Now, when we add it to the portal we can click the “Configure” button next to it on the Modules tab and we’ll see our properties for “TeamName and MenuItemID. We’d change the code to use those property values, instead of the hard coded ones, and then the administrator could simply use the Configure button to see the properties listed and enter the TeamName and MenuItemID to remove for anyone not on that team. Then a redeploy and the changes are live. Now you can change the values easily, without touching the code, or even reuse the module for something else.

If you want to take a look at the completed DLL (with the hard coded values), I’ve attached the Visual Studio project to this post (it will look for the references Sage DLLs in the usual Copy Assemblies location C:Program FilesSalesLogixReferenceAssemblies).

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Ryan Farley
Ryan Farleyhttps://customerfx.com/article/author/ryanfarley/
Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

1 COMMENT

  1. Ryan

    Excellent blog, this helped me loads.

    Henry

    are you getting the workspace using NavWorkspace instead of ToolbarWorkspace ?

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Infor CRM SLX 10.0: Delegate Ownership Changes for “Everyone” Records

Learn how the new EveryoneOwnerAssignment secured action in Infor CRM SLX 10.0 allows designated users to change ownership of Everyone-owned records without requiring Administrator access.

Related Articles

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Related Videos