Infor CRM (Formerly Saleslogix) Iterating through all tabs on a Page

Using the TabWorskpace you can iterate through all the tabs on a page and do something with them, like show or hide them.  To do this you need the following code:

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;
    }
}

protected void QuickFormLoad0()
{
    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)
        {            
            foreach (Sage.Platform.WebPortal.Workspaces.Tab.TabInfo sp in tabContentWorkspace.Tabs)
            {                
                tabContentWorkspace.Hide(sp.ID, true);   
            }
        }
    }
    catch { }
}
ABOUT THE AUTHOR

Kris Halsrud

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

10 Comments

  1. Hi Kris,

    For the Account page, what quick form’s Load action holds the code snippet? QuickFormLoad0 of AccountDetails OR QuickFormLoad0 of any tabs?

    Thanks
    xdp

    Reply
  2. Our Infor CRM web is 8.3. Actually, I want to customize the code to set default tab. For example, when opening Account page, the Contacts tab is displayed by default. Is it possible?

    Reply
    • The default tab is based on settings stored in the VFS table for each user. The path for this setting in the VFS for the admin user would be: \Configuration\Application_User\SlxClient\admin\ASP.account_aspxDetail\TabWorkspace-E53DA2EE-942A-4b9d-8885-55C2EF1A4E4A.xml

      Inside the xml of that is a node ActiveMainTab which stores the smart part name of the tab that is defaulted.

      I think you would somehow need to update this VFS record for each user on the load of the account form. I am not sure if that would happen early enough to make the tab the active one or if it would happen too late. Never tried doing this specifically.

  3. Using your code for hiding/showing tabs, we can get the tab collection of the current Account, right? From the tab collection, is it possible to locate a certain tab which we want and then set it as displayed (active?) with code (e.g. a method) on the fly?

    Reply
    • Not sure but I doubt it. The tab selection is client side and this would be server side code. I would guess the only server side way would be as I mentioned to change the default tab in the VFS settings prior to the tabs being opened. Perhaps with client side jscript you could do so, but not sure.

  4. Thanks Kris!

    Reply
  5. foreach (Sage.Platform.WebPortal.Workspaces.Tab.TabInfo sp in tabContentWorkspace.Tabs)
    ———————————-

    tabContentWorkspace.Tabs is a tab collection, right?

    For this line, sp is Tabinfo. Is there a method or property which can return tab?

    Reply
  6. Or tabContentWorkspace is that tab collection?

    Reply
  7. Maybe can use tabContentWorkspace.Activate(object smartpart), but don’t know how to get/create the smartpart object, e.g. the object of Contacts quickform.

    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) news and product updates!

You have Successfully Subscribed!