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
Michael_MantouvalosMichael_Mantouvalos 

when button pressed, redirect to a specific report in salesforce (NOT with direct URL)

Hi everyone,

I have a procedure that creates some data from a aura component page. This component uses a form and a submit button. This button (submitRecord function below) creates the data and then i navigate to a custom report to view that data. I need a way so when i press that button and the records get created, then to be redirected to this custom report page directrly. I used this :  window.location.href = 'link_of_custom_report' and it worked. Instead i need to relocate dynamicaly and not with a direct link. Is there a way to do so? Thanks in advance!

controller: 

({
    submitRecord : function(component, event, helper) {
        var action = component.get("c.createSummaryRecordsFromSpecicDates");
        action.setParams({"setDateFrom" : component.get("v.startDate"),
                          "setDateTo" : component.get("v.endDate")
        });
        action.setCallback(this, function(result){
            var state = result.getState();
            if (component.isValid() && state === "SUCCESS"){
               ********** i need something here in order to redirect to my reports page **********
            }
        });
        $A.enqueueAction(action);
    }
})

ShirishaShirisha (Salesforce Developers) 
Hi Michael,

Greetings!

You can use lightning:navigation component to direct to the particular record or page according to your requirement.Please find the example in the below document:https://developer.salesforce.com/docs/component-library/bundle/lightning:navigation/documentation

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri