3

This is supposed to be sort of official method:

public static String getActiveTab(){
    String tabLabel;
    for(Schema.DescribeTabSetResult i : Schema.describeTabs()) {
        if(i.isSelected()) {
            tabLabel = i.getLabel();
            break;
        }
    }
    return tabLabel;
}

However what is returns is App that I have selected in Classic. It seems App selection between modes is completely different. I think it has to do something with how Lightning Apps is actually different metadata type.

FWIW I did notice that switching from Lightning to Classic in a scratch org, occasionally defaults me to Service Console app. When snippet above is executed in Lightning, by default it returns 'Service Console'.

  • Had brainfart and had typed in "in Apex" when meant in "Classic". When executing from Classic context result is not the same as executing in Lightning context. – dzh Aug 29 '18 at 21:40
  • Probably has to do something with Lightning apps being essentially different type of an app / metadata. – dzh Aug 29 '18 at 21:41
  • I'd suggest asking questions to those who find this unclear... – dzh Sep 13 '18 at 3:05
  • I'm voting to leave this post closed as it doesn't contain a question. If you edit the contents to at least ask something, it seems likely to be on topic. – Adrian Larson Sep 13 '18 at 4:17
  • @AdrianLarson I've rewritten the question, hope this time it's more clear. – dzh Sep 19 '18 at 8:04

Browse other questions tagged or ask your own question.