Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
New Member
Posts: 6
Registered: ‎05-29-2012

Problem hiding tabs at runtime Web 7.5.4

I have tried to dynamically hide tabs at runtime using code, based on http://customerfx.com/pages/integrationblog/2012/05/01/a-realy-cool-nugget-how-to-show-and-hide-tabs... but cannot get it to work. IsHidden changes to true, but the tab remains visible and active.

 

Am I missing something? What does the article mean by "present as a loaded smart part"? I have tried it on a tab both when still in More Tabs as well as after moving.

 

I get no errors during compilation or at runtime.

I have the following C# snippet code in the quickformload of AccountDetails

if (Convert.ToString(Page.Session["Country"]) == "BFR")
{
Sage.Platform.WebPortal.Workspaces.Tab.TabWorkspace tabs =
this.ParentWorkItem.Workspaces["TabControl"] as
Sage.Platform.WebPortal.Workspaces.Tab.TabWorkspace;

tabs.Hide("C_BFR_Club", true);
}

We use multiple, country dependant databases. Hence the first line.

Employee
Posts: 85
Registered: ‎04-01-2009

Re: Problem hiding tabs at runtime Web 7.5.4

Could the Application Architect help topic, "Hiding/Unhiding a Tab at Run-Time", give you any ideas?

New Member
Posts: 6
Registered: ‎05-29-2012

Re: Problem hiding tabs at runtime Web 7.5.4

Thanks for the reply.

 

As far as I can see,  my code is essentially the same - get a reference to the tab workspace and call the Hide method.

 

As I said originally, the Hide appears to work in that InHidden changes from false to true.  However, the page does not hide.

 

Could it be a timing issue?  i.e. I am trying to hide a page that is not yet loaded.  The original article said the page must be "present as a loaded smart part", but I am not sure what he meant or how to achieve it.

Employee
Posts: 535
Registered: ‎03-30-2009

Re: Problem hiding tabs at runtime Web 7.5.4

That code actually needs to go into an external assembly (DLL). You add that DLL to the SupportFiles\Bin folder, and then in the AA Portal configuration you add that DLL to the list of portal "Modules".

 

Due to how the Tab area is created and managed, that code needs to execure much earlier in the process.

 

There is one example in the stock product. On the Account MainView page, there is a tab for "Reseller Opportunities" that will only be made visible when Account.Type = "Reseller".

 

The assembly module name is:  Sage.SalesLogix.Client.Account.Modules.dll

Use reflector to examine the code for Show/Hide of the Reselelr Opportunities tab.

 

I believe that Mike LaSpina, or I may have posted a Visual Studio project and source code example at some point. If you are nto able to find that on this site please let me know and I will try to locate the example and re-post.  The code from the Help file topic is what is needed, but just need to create it in an external assembly with the correct references, etc..

Todd Hardin
SalesLogix Professional Services Group
Employee
Posts: 535
Registered: ‎03-30-2009

Re: Problem hiding tabs at runtime Web 7.5.4

Correction - I think the logic is that the if Account.Type = "Partner" then Show the Reseller Opportunities tab, otherwise hide tab.

 

The more important point of course is that this code goes into an external .Net Assembly that is an Page module in the Sage SalesLogix architecture.

Todd Hardin
SalesLogix Professional Services Group
Bronze Super Contributor
Posts: 236
Registered: ‎03-30-2009

Re: Problem hiding tabs at runtime Web 7.5.4

[ Edited ]

This is the code that would hide tabs on the account page.  Be sure to include the following references in your project:

  • Sage.Entity.Interfaces
  • Sage.Platform
  • Sage.Platform.Application
  • Sage.Platform.Application.UI.Web
  • Sage.Platform.WebPortal
  • Sage.SalesLogix.Client.GroupBuilder
  • Sage.SaelsLogix.Security
  • Sage.SalesLogix.Web

I typically just set the reference search path to the bin folder of the SLX website and then add these specific references in.  After building, add this module to the page (Account Detail in this case).  This example will hide the tab "CutomerDetails" if the account is not of type "Cutomer".

 

using System;
using System.Collections.Generic;
using System.Text;

using Sage.Platform.WebPortal;
using Sage.SalesLogix.Client.GroupBuilder.Controls;
using Sage.Platform.WebPortal.Services;
using Sage.Platform.WebPortal.SmartParts;
using Sage.Platform.WebPortal.Workspaces;
using Sage.Platform.WebPortal.Workspaces.Tab;
using System.Web;
using Sage.SalesLogix.Security;
using Sage.SalesLogix.Web;
using Sage.Platform.Security;
using Sage.Entity.Interfaces;
using Sage.Platform;
using Sage.Platform.Application;
using Sage.Platform.Application.UI;
using Sage.Platform.Application.UI.Web;


namespace SagePSG.SalesLogix.Client.Account.Modules
{
    public class AccountModule : IModule
    {
        private IPageWorkItemLocator _pageWorkItemLocator;
        [ServiceDependency]
        public IPageWorkItemLocator PageWorkItemLocator
        {
            get { return _pageWorkItemLocator; }
            set { _pageWorkItemLocator = value; }
        }

        private IEntityContextService _EntityService;
        [ServiceDependency(Type = typeof(IEntityContextService), Required = true)]
        public IEntityContextService EntityService
        {
            get
            {
                return _EntityService;
            }
            set
            {
                _EntityService = value;
            }
        }


        #region IModule Members

        public void Load()
        {
           
            IAccount account = EntityFactory.GetById<IAccount>(EntityService.EntityID.ToString());
            if (account != null)
            {
                PageWorkItem workItem = PageWorkItemLocator.GetPageWorkItem();
                TabWorkspace tabWorkspace = workItem.Workspaces["TabControl"] as TabWorkspace;

                if (account.Type == "Customer")
                {
                    tabWorkspace.Hide("CustomerDetails", false);    
                }
                else
                {
                    tabWorkspace.Hide("CustomerDetails", true);    
                }
            }
        }

        #endregion
    }
}

 

 

 

 

 

Mike LaSpina
Professional Services Consultant

Sage
8800 N Gainey Center Dr Ste 200
Scottsdale AZ 85258
Tel: 480-383-5344
Cell: 480-321-6637
Fax: 480-556-4090
mike.laspina@sage.com

Your Business in Mind.
New Member
Posts: 6
Registered: ‎05-29-2012

Re: Problem hiding tabs at runtime Web 7.5.4

Thanks very much, Todd and Mike.  That works.  Problem solved

Copper Contributor
Posts: 22
Registered: ‎08-17-2009

Re: Problem hiding tabs at runtime Web 7.5.4

When I copy this code into a new Class project I get this error:

 

Sage.Platform.Application.ServiceDependencyAttribute' is not an attribute class 

 

The following two sections are causing the error:

 

private

IPageWorkItemLocator_pageWorkItemLocator;

[ServiceDependency]  //THIS IS CAUSING THE ERROR

publicIPageWorkItemLocatorPageWorkItemLocator

{

get { return_pageWorkItemLocator; }

 

set { _pageWorkItemLocator = value; }

}

privateIEntityContextService_EntityService;

//THIS IS CAUSING THE ERROR [ServiceDependency(Type =

typeof(IEntityContextService), Required = true)]

 

publicIEntityContextService EntityService

 

 

Mike Fortier

BrainSell Technologies

mfortier@brainsell.net

 

Copper Contributor
Posts: 22
Registered: ‎08-17-2009

Re: Problem hiding tabs at runtime Web 7.5.4

Never mind, I need to add the reference to Microsoft.Unity

 

Mike Fortier

BrainSell Tech.

Copper Super Contributor
Posts: 172
Registered: ‎07-06-2010

Re: Problem hiding tabs at runtime Web 7.5.4

this would work perfectly, except that I cannot get App Arch to pick up my assembly that's added to the bin directory. I've tried shutting down and reloading the whole project and it is never listed among the module types.