In the visualforce page, we hard coded the URL link - "Go To List" to show all related account contact role records in a visualforce page. Classic view is working just fine. However, the link is lost when user click in Lightning environment. it only display recent view list view for account contact role object. I am trying to detect user's theme and determine which URL is directing user, but can't get the URL work. Please help! thanks!

public PageReference displayAll() {
        try {
            IGT_AccountContactRole__c contactRole = (IGT_AccountContactRole__c) ssc.getRecords().get(0);

            Schema.DescribeSObjectResult objDesc = IGT_AccountContactRole__c.SObjectType.getDescribe();
            String prefixId = objDesc.getKeyPrefix();

            ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.Info, prefixId));
            String userTheme = UserInfo.getUiThemeDisplayed();
            String url;
            if(userTheme == 'Theme2' || userTheme =='Theme3'){
              url = '/' + prefixId + '?rlid=00Na000000BA8BX&id=' + contactRole.Account__r.Id;  
              ???????????????????????? //need help on how to format URL
            PageReference nextPage = new PageReference(url);

            return nextPage;

        } catch(Exception e) {ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.Error, e.getMessage()));return null;}

Your Answer

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

Browse other questions tagged or ask your own question.