1

I implemented a redirect from the community home page to the logged in user's account page on our customer community following this blog post: https://www.crmscience.com/single-post/2016/09/26/Dynamic-Navigation-in-Napili-Communities. It has been working fine but has recently stopped working - I suspect as result of Winter '21 release. Now the home page doesn't redirect - url doesn't change and just displays the home page which is blank (its only content is the myAccountRedirect component). I can't figure out why - can anyone shed any light on this?

Here is the code:

public class NapiliCommunityController {
@AuraEnabled
public static User getLoggedInUser(){
    return [SELECT Id, Contact.AccountId FROM User WHERE Id =: UserInfo.getUserId() LIMIT 1];
}

}

<aura:component controller="NapiliCommunityController" implements="forceCommunity:availableForAllPageTypes" access="global">
<aura:handler name="init" value="{!this}" action="{!c.redirectToAccount}" />

</aura:component>

({
redirectToAccount: function(component, event, helper) {
    var loggedInUser;
    var state;
    var navEvt;
    
    var action = component.get("c.getLoggedInUser");
    action.setCallback(this, function(response) {
        state = response.getState();
        if (state === "SUCCESS") {
            loggedInUser = response.getReturnValue();
            navEvt = $A.get("e.force:navigateToSObject");
            navEvt.setParams({
                "recordId": loggedInUser.Contact.AccountId,
                "slideDevName": "detail"
            });
            navEvt.fire();
        }
    });
    $A.enqueueAction(action);
}

})

0

Enable the NapiliCommunityController apex class to the profile the community user uses. After the Winter '21 release, Apex classes have to be added to the profiles.

Reference:https://releasenotes.docs.salesforce.com/en-us/winter20/release-notes/rn_lc_restrict_apex_guest_users.htm

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.