1

I have a lightning component thats used in LEX, Classic, and a community. The component redirects the user to a record detail page after an action occurs. I am trying to implement UserInfo.getUiThemeDisplayed() to redirect the user to the correct place depending on the UI theme they are on.

However, in the lightning community it's returning theme3 as the value, I am expecting PortalDefault or Theme4d in the correct themes list

Component:

var locationAction = component.get('c.getLocationTheme');
locationAction.setCallback(this, function(response) {
    console.log('Location: ' + response.getReturnValue());
});
$A.enqueueAction(locationAction);

Apex:

@AuraEnabled
public static String getLocationTheme() {
    return UserInfo.getUIThemeDisplayed();
}

Debug: Location: Theme3

Is this expected behavior? What is the correct way of knowing where your lightning component instance is?

2

Ended up just writing my own method to get around it.

@AuraEnabled
public static String getLocationTheme() {
    if (Site.getSiteId() != null) {
        return COMMUNITY;
    } else if (UserInfo.getUIThemeDisplayed() == 'Theme3') {
        return CLASSIC;
    } else {
        return LEX;
    }
}
0

If we active the "Enable the Lightning Console UI Theme" and will not change any thing for the existing Visualforce pages will it effect anything existing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.