-1

Controller -

appNavigation : function(component, event, helper) {
        var action=  component.get('c.getAllApps'); 
        console.log(action);
        action.setCallback(this,function(response){
            if("SUCCESS"===response.getState())
            {

            console.log('response'+JSON.stringify(response.getReturnValue()));
            var ReturnValueID = response.getReturnValue();
                console.log(ReturnValueID[0].ApplicationId);
                console.log(ReturnValueID[1].ApplicationId);
                console.log(ReturnValueID[2].ApplicationId);
            }
                var ReturnValueID = response.getReturnValue();
                if(ReturnValueID[0].ApplicationId='02uf4000001NrwqAAC')
                {
                      "type": "standard__app",
                          "attributes": {      //Line Number 35
                              "appTarget": "standard__Sales",
                            }
                }
        });
        $A.enqueueAction(action);


    }
}) 

Description - I have created a custom Lightning app Launcher for three app sales,serivce and marketing, I want when user click on particular application it should navigate to related application home page.

Error - enter image description here

Apex Class -

public class GLobalNavigationAppClass {
    @AuraEnabled
    public Static List<AppMenuItem> getAllApps(){
        return [Select Id,Type,ApplicationId,Name,Label,Description,IconUrl,StartUrl,InfoUrl,IsAccessible,IsVisible,LogoUrl,
                SortOrder,MobileDeviceType from AppMenuItem where IsAccessible=true AND Type='TabSet' AND ID in ('0DSf4000000xV7VGAU','0DSf4000000xV7UGAU','0DSf4000000xV7WGAU') order by Name ASC];
    }

} 
0

You need to use navigation service and pagereference types available in Lightning Aura components. Use lightning:navigation component to navigate to a given pageReference or to generate a URL from a pageReference. The pageReference type generates a unique URL format and defines attributes that apply to all pages of that type.

Component:-

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes">
    <lightning:navigation aura:id="navService"/>
</aura:component>

Controller:-

appNavigation : function(component, event, helper) {
    var action=  component.get('c.getAllApps'); 
    console.log(action);
    action.setCallback(this,function(response){
        if("SUCCESS"===response.getState())
        {                
            var ReturnValueID = response.getReturnValue();
        }
        var ReturnValueID = response.getReturnValue();
        if(ReturnValueID[0].ApplicationId='02uf4000001NrwqAAC')
        {
            var navService = component.find("navService");
            // Sets the route to /lightning/app/standard__Sales
            var pageReference = {
                type: "standard__app",
                attributes: {
                    appTarget: "standard__Sales",
                }
            };
            //navigate to the app
            navService.navigate(pageReference);
        }
    });
    $A.enqueueAction(action);
}
  • @Sanket, According to above code my Page is coming into navService as per console.log, but my page is not navigating to particular Sales application page.And I am Running my component from lightning application is it the correct way to open particular application or it need to be add in any record page. – Sangeet Dec 12 '19 at 4:35
  • 1
    I found the solution against this, Salesforce give an update on Salesforce Winter ’20 Release Notes to navigate user directly to an App URL- releasenotes.docs.salesforce.com/en-us/winter20/release-notes/… – Sangeet Dec 12 '19 at 11:29

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.