8

I have an appexchange application which is going to be installed in customer orgs. I need to show a sidebar component if the app selected from app menu is my installed package. When I change the app menu from the installed package to something else I need to hide the side bar component. I know this can be done by javascript depending on the DOM structure of salesforce app menu but it is dangerous as Salesforce can change at any time. So please let me know is there any work around to detect the salesforce active app / change in active app.

2 Answers 2

7

You can use the describeTabs method to list the current applications and determine if the selected app is the one your looking for. I created a HTML side bar component with an IFRAME containing this page, when i switch applications it updates with accordingly.

enter image description here

enter image description here

<apex:page controller="MyAppController" showHeader="false" sidebar="false">{!message}</apex:page>

The following displays the message accordingly..

public with sharing class MyAppController {

    public String getMessage()
    {
        String appName = 'Sales';

        // Get tab set describes for each app
        List<Schema.DescribeTabSetResult> tabSetDesc = Schema.describeTabs();

        // Iterate through each tab set describe for each app and display the info
        boolean selected = false;
        for(Schema.DescribeTabSetResult tsr : tabSetDesc) {
            if (tsr.getLabel() == appName) {
                selected = tsr.isSelected();
                break;   
            }           
        }       

        // Selected?
        return selected ? 'Sales selected' : 'Sales not selected';
    }
}
1
  • Your welcome, been looking for a good way to play with the describeTabs API since it was added, thanks for the chance! :-) Commented Jan 16, 2014 at 6:47
2

When you select an App from the drop down the App ID is included in the query string against tsid parameter. E.g.

/home/home.jsp?tsid=02u300000000vNR

Maybe you could check for this query string parameter and ID with the 02u (TabSet) keyprefix in you side bar component. When it is detected set a cookie to remember the last known app value. Then have a custom setting that indicates which TabSet/App Id your component should be active for.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .