In Infor CRM Web (Saleslogix), when a user navigates to a page, there might be times when you want to draw attention to a particular tab. There are some options for specifying the active/displayed tab on the page. Let’s take a look at some of the options.
Specifying the Active Tab in the URL
You can add a parameter to the query string, or URL, to set the active/displayed tab. The activeTab parameter allows you to specify a tab by it’s ID (the ID is set when the SmartPart is added to a page. Look at the SmartParts for the page and you’ll see it’s “Smart Part ID” there).
For example, when redirecting a user to the Account page, if you want to display the Assets tab, you can use the following URL:
http://localhost:3333/SlxClient/Account.aspx?entityid=AGHEA0002669&activeTab=AccountAssets
It doesn’t matter if the tab is in the More Tabs, or it’s own tab, it will display as the active tab.
Programmatically Setting the Active tab
You can also set the active tab on demand from a LoadAction or other event or control change action. To do this, you’ll need to inject some Javascript onto the page. Also, since a tab can either be a real tab, or can be located under the “More Tabs” tab, you’ll need the Javascript check to see where the tab is at. If the tab is under the More Tabs tab, you’ll need to also activate the “More Tabs” tab first, and then activate the tab you want to show. That sounds more complicated than it is. The code looks like this (in this sample, we’re showing the Assets tab again:
// Server-side code for adding to LoadAction or control change action // this is the ID of the tab you want to show var tabIdToSelect = "AccountAssets"; // leave these lines as they are var script = "var prefix = 'show'; if ($('#show_More').nextAll('#show_" + tabIdToSelect + "').length) { $('#show_More').click(); prefix = 'more'; } $('#' + prefix + '_" + tabIdToSelect + "').click();"; ScriptManager.RegisterClientScriptBlock(this, GetType(), "tabSelect_Script", script, true);
That code can be added in a LoadAction or change event of a control. This comes in handy when you want to conditionally show a certain tab.
If you need to set the active tab via client-side Javascript, the code looks like this (same code as above, just with the server-side stuff removed)
// Client-side javascript // this is the ID of the tab you want to show var tabIdToSelect = 'AccountAssets'; var prefix = 'show'; if ($('#show_More').nextAll('#show_' + tabIdToSelect + '').length) { $('#show_More').click(); prefix = 'more'; } $('#' + prefix + '_' + tabIdToSelect).click();
Specifying the Default Tab for the Page
If you always want a certain tab to show for a page, you can set that for the page itself in Application Architect. To set this, open the page in AA, click the “Configure” button in the Template Information section, then set the tab’s ID as the value for the OverrideActiveTab property. See the following screenshot:
Wanted to update this for 8.1+ for all that need to use it. At least for 8.1, the activeTab URL parameter causes the client loading to fail for any other tab then the one referenced. If you add the below code to the base.master (or main.master for 8.3), you can call this with the URL parameter “setTab” or you can call the javascript function from the server by passing in the tab name to RegisterStartupScript:
if (getParameter(“setTab”))
{
setTab(getParameter(“setTab”));
}
function setTab(tab)
{
setTimeout(function () {
var prefix = ‘show’;
if ($(‘#element_More’).find(‘#more_’ + tab + ‘:visible’).length) {
$(‘#show_More’).click(); prefix = ‘more’;
}
$(‘#’ + prefix + ‘_’ + tab).click();
}, 2000);
}
function getParameter(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, “\\$&”);
var regex = new RegExp(“[?&]” + name + “(=([^&#]*)|&|#|$)”),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return ”;
return decodeURIComponent(results[2].replace(/\+/g, ” “));
}