05-29-2012 01:11 PM
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.
05-29-2012 01:52 PM
Could the Application Architect help topic, "Hiding/Unhiding a Tab at Run-Time", give you any ideas?
05-29-2012 06:13 PM
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.
05-30-2012 10:15 AM
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..
05-30-2012 12:33 PM
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.
05-30-2012 01:33 PM - edited 05-30-2012 01:34 PM
This is the code that would hide tabs on the account page. Be sure to include the following references in your project:
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 } }
06-05-2012 04:53 AM
Thanks very much, Todd and Mike. That works. Problem solved
07-05-2012 01:43 PM
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
07-06-2012 03:12 AM
Never mind, I need to add the reference to Microsoft.Unity
Mike Fortier
BrainSell Tech.
08-06-2012 02:16 PM
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.