Infor CRM (Formerly Saleslogix) Hiding Tabs at Runtime Without Using Modules

 As Ryan wrote a long time ago, you can create a module and add it to a page in the Infor CRM web client to show or hide things like menus, or tabs.

Problem is that this functionality doesn’t work well starting in 8.1 with update 05 as the modules no longer run as you switch records client side, using the group pane or VCR group navigator buttons.  This means the module runs the first time you open the page but not subsequently as you switch records unless you do a full refresh again.  This problem is detailed here.

Creating modules seems overkill and a big pain to make this happen.  What you can do instead is to use similar code either directly on a quick form, in the load action, or by creating a global code file in the app_code folder and then calling that directly. 

To load it onto a quick form you need to get a little creative.  Quick forms only offer the ability to add a single function at a time and we will need to add some variables and service dependencies.  This can be done by messing with how quick forms get rendered.  if you think about when you add code to the load action you simply type in the code you want and then when the smart part is constructed it wraps your code in a code stub.  So if you did something like this in a load action:

string myVar = “hello there”;

When the quick form is deployed it becomes

protected void QuickFormLoad0 ()

{

   string myVar = “hello there”;

}

So what this means is we can add our own code and add an extra } at the end, that way we could type something like:

   string myVar = “hello there”;

}

protected void myCoolFunction()

{

string myVar = “I fooled  Saleslogix.  Yah!”;

That way when it is built we end up with

protected void QuickFormLoad0 ()

string myVar = “hello there”;

}

protected void myCoolFunction()

{

string myVar = “I fooled  Saleslogix.  Yah!”;

}

 The important thing to notice is I add one extra } after my load action code and leave off the closing } after my custom function.

On to the details

So with knowing that, lets take a look at how we do this:

The first thing is to add our code that will run on the load action:

    Sage.Platform.WebPortal.Workspaces.Tab.TabWorkspace tabContentWorkspace = null;
    try
    {
        string id = string.Empty;
        tabContentWorkspace = this._parentWorkItem.Workspaces[“TabControl”] as Sage.Platform.WebPortal.Workspaces.Tab.TabWorkspace;
        Sage.Platform.Application.IEntityContextService entityContext = this._parentWorkItem.Services.Get<Sage.Platform.Application.IEntityContextService>();
        if (entityContext.HasEntityContext)
        {
            id = entityContext.EntityID.ToString();
        }
        Sage.Entity.Interfaces.IAccount buyer = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.IAccount>(id);

        if (tabContentWorkspace != null && buyer != null && !string.IsNullOrEmpty(buyer.Type))
        {
            string type = buyer.Buyer.ToLower();
            foreach (Sage.Platform.WebPortal.Workspaces.Tab.TabInfo sp in tabContentWorkspace.Tabs)
            {               
                tabContentWorkspace.Hide(“someTabID”, type == “prospect”);  
            }
        }
    }
    catch (Exception exception)
    {
       throw new Sage.Platform.Application.ValidationException(“oops we have a problem”);
    }

}

Again notice, I have an extra } at the end.  Now right below this we need to add some dependencies our code is using:

private Sage.Platform.Application.UI.UIWorkItem _parentWorkItem;
[Sage.Platform.Application.ServiceDependency(Type = typeof(Sage.Platform.Application.WorkItem))]
public Sage.Platform.Application.UI.UIWorkItem ParentWorkItem
{
    get
    {
        return this._parentWorkItem;
    }
    set
    {
        this._parentWorkItem = value;
    }

Again, notice I have left off the last closing bracket.

This code sample assumes this is running on the account screen and will run when the quick form loads and hide the smart part tab called “someTabID” when the current account’s type=”Prospect”

Please note I have only had success using this when there are no other modules on the page :(.  Using on a standard screen like Account details doesnt seem to work as other modules override what we are doing here, so for thos a module approach is still the way to go.  BOOO!

 

ABOUT THE AUTHOR

Kris Halsrud

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

1 Comment

  1. Hi, Kris,

    Have you found solution to this problem?
    – Hiding Tabs at Runtime at Account delails

    Regards,
    Denis

    Reply

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!