function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rajesh T 19Rajesh T 19 

How to navigate the Aura lightning component(embed in VF Page) to Case Record page or Case list view page on Community ?

On community Case detail page, I have used custom button to invoke VF which invoking aura component. After all the scenarios am trying to redirect the user to same record page or to case list view based on user response but it's not working. However the below code working on Lightning and classic context.

Not working on page redirect:
window.location.href = '/'+caseId;
window.location.href = '/'+casekeyprefix;

Aura component:
<aura:component controller="casecontroller" implements="force:appHostable,flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:lightningQuickActionWithoutHeader,force:hasRecordId,force:appHostable,flexipage:availableForAllPageTypes" access="global" >
    <!--Attributes-->
    <aura:attribute name="caseId" type="Id"/>
    <aura:attribute name="source" type="String"/>
    <aura:attribute name="showModal" type="boolean" default="false"/>
     <aura:attribute name="Spinner" type="Boolean" default="false"/>
     <!--Aura Handler-->    
    
    <aura:handler event="aura:waiting" action="{!c.showSpinner}"/>
    <aura:handler event="aura:doneWaiting" action="{!c.hideSpinner}"/>
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>
    
    <aura:handler event="force:navigateToSObject" action="{!c.navigate}"/>
    
         <!--loading spinner start... style=Brand Medium (blue dots)-->
     <aura:if isTrue="{!v.Spinner}">
        <div aura:id="spinnerId" class="slds-spinner_container">
           <div class="slds-spinner--brand  slds-spinner slds-spinner--large slds-is-relative" role="alert">
             <span class="slds-assistive-text">Loading</span>
             <div class="slds-spinner__dot-a"></div>
             <div class="slds-spinner__dot-b"></div>
           </div>
        </div>
     </aura:if>
      <!-- Loading spinner end--> 
    
     <aura:if isTrue="{!v.showModal}">
            <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" 
aria-modal="true" aria-describedby="modal-content-id-1" 
class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <header class="slds-modal__header">
                        <lightning:buttonIcon iconName="utility:close"
                                              onclick="{! c.hideModel }"
                                              alternativeText="close"
                                              variant="bare-inverse"
                                              class="slds-modal__close"/>
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">
User Confirmation</h2>
                    </header>
                    <!--Modal/Popup Box Body Starts here-->
    <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                        <p><b>Please click Ok button to delete the case or click cancel button to re-direct to Draft case. 
                            </b>
                        </p>
                    </div>
                    <!--Modal/Popup Box Footer Starts here-->
                    <footer class="slds-modal__footer">
                        <lightning:button variant="neutral"
                                          label="Cancel"
                                          title="Cancel"
                                          onclick="{! c.tocasepage }"/>
                        <lightning:button variant="brand"
                                          label="OK"
                                          title="OK"
                                          onclick="{!c.deletecase}"/>
                    </footer>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>
        </aura:if>
</aura:component>

Controller.Js:
({
    init : function(component, event, helper) {
        var caseId = component.get("v.caseId");
        var action = component.get("c.validatecaseexist");
        action.setParams({ "caseId" : caseId});
        action.setCallback(this, function(response) {
            var state = response.getState();
            console.log('state:: '+ state);
            if (state === "SUCCESS") {
                var ispresent = response.getReturnValue();
                if(ispresent === "True"){
                    component.set("v.showModal", true);
                }
                else if(ispresent === "False"){
                    
                }
            }
            else{
                console.log('Error in Init');
            }
        });
       $A.enqueueAction(action);
    },
    tocasepage : function(component, event, helper) {
        var caseId = component.get("v.caseId");
        window.location.href = '/'+caseId;
    },
     deletecase : function(component, event, helper) {
        var getcaseId = component.get("v.caseId");
        console.log('CasegetID:: '+ getcaseId);
        var casekeyprefix = getcaseId.substring(0, 3);
        var action = component.get("c.deletecasedetails");
        action.setParams({ "caseId" : getcaseId});
         console.log('CasegetID:: '+ getcaseId);
         action.setCallback(this, function(response) {
            var state = response.getState();
            console.log('state:: '+ state);
             if (state === "SUCCESS") {
                 var Isdeleted = response.getReturnValue();
                 if(Isdeleted === "True"){
                    window.location.href = '/'+casekeyprefix;
                }
                 else if(Isdeleted === "False"){
                    window.location.href = '/'+caseId;
                 }
             }
         });
         $A.enqueueAction(action);
    },
        // this function automatic call by aura:waiting event  
    showSpinner: function(component, event, helper) {
       // make Spinner attribute true for display loading spinner 
        component.set("v.Spinner", true); 
        console.log('inside show spinner');
   },
    
     // this function automatic call by aura:doneWaiting event 
    hideSpinner : function(component,event,helper){
     // make Spinner attribute to false for hide loading spinner    
       component.set("v.Spinner", false);
    }  
})

Application:
<aura:application access="GLOBAL" extends="ltng:outApp">
    <aura:dependency resource="c:DraftCaseDeletion_Comp"/>
</aura:application>

I'm new to Aura lightning and Community site, can anyone help me on how to navigate to case record page or case list view ? 
Suraj Tripathi 47Suraj Tripathi 47
Hi Rajesh T 19
 

Greeting!

Take reference to this link below. It might help you navigate to the aura component.

https://salesforce.stackexchange.com/questions/322065/using-lightninglistview-in-vf-page

If you find your solution please mark this as the best answer.

Thank you!
Regards,
Suraj Tripathi