fiogf49gjkf0d Hello,
I am trying to hide/unhide tabs based on Account Type. I was able to hide/unhide tabs from Account.aspx.cs using TabWorkspace, however, I'm not sure how to go about determining the current Account Type. On any given smartpart I would typically use:
Sage.Entity.Interfaces.IAccount account = (Sage.Entity.Interfaces.IAccount)this.BindingSource.Current;
But in Account.aspx.cs, I get the error: this.BindingSource does not exist...
I have a feeling I know why this occurs but I'm not sure of a way to workaround.
It is interesting that the AA Help file has instructions to do my specific task (I found it right after I had figured out the hide/unhide code), however, that code does not work.
Here is the help file code:
<h1>Hiding/Unhiding a Tab at Run-Time
You can hide and unhide a tab using code in a module. Take as an example Sage.SalesLogix.Client.Account.Module which among other things, controls the display of the AccountResellerOpportunities tab on the Account Detail page. If the account type is not 'Partner', it hides the tab. If the account type is 'Partner', it unhides the tab. Note that the explicit unhide is required since the tab state persists.
This was accomplished through code in the AccountModule.cs using the Hide method of tabWorkspace to hide and unhide.
public void Load()
{
I Account account = EntityFactory.GetById<IAccount>(EntityService.EntityID.ToString());
if (account != null)
{
PageWorkItem workItem = PageWorkItemLocator.GetPageWorkItem();
TabWorkspace tabWorkspace = workItem.Workspaces["TabControl"] as TabWorkspace;
if (account.Type != Resource.ACCOUNT_TYPE_PARTNER)
{
// Hide
tabWorkspace.Hide("AccountResellerOpportunities", true);
}
else
{
// Unhide
tabWorkspace.Hide("AccountResellerOpportunities", false);
}
}
}
First, PageWorkItem and TabWorkspace need to have the full path to their assembly in front.
This is the code I used instead:
Sage.Platform.WebPortal.Workspaces.Tab.TabWorkspace workspace = this.PageWorkItem.Workspaces["TabControl"] as Sage.Platform.WebPortal.Workspaces.Tab.TabWorkspace;
So now I just need to find Account Type by using:
I Account account = EntityFactory.GetById<IAccount>(EntityService.EntityID.ToString());
Even when I fix it to:
Sage.Entity.Interfaces.IAccount accout = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.IAccount>(EntityService.EntityID.ToString());
I get the error:
The name 'EntityService' does not exist in the current context
Any ideas? |