Skip to Content
Author's profile photo Sri Divya

Cross-app Navigation in SAP Fiori launchpad

In this blog, I would like to discuss on Cross-app navigation, which is from one SAP UI5 application to the other in the SAP Fiori launchpad.

I have created two  SAP UI5 applications:

  1. app1 consist of an “employee Id” field and a “get employee Id” button.
  2. app2 Consist of a simple text.

In the Fiori launchpad, I am calling app2 from app1.

In case of internal navigation in the SAP UI5, which is from one view to the other view / from one page to other: we define our root view, patterns and targets.

In the same way, in order to achieve cross-app navigation in SAP Fiori we define intents in the SAP UI5 application. Intents acts as a target and is mapped with the actual URL at run time. Intents comprises of a semantic object and action to be performed.

Our goal is to navigate to app2, so in the app2 we need to define the intents. In the navigation tab of manifest.json file provide the semantic object name and action to be performed as display

Now in the first application ( app1 ) write the code in the controller as follows.

	onPress: function(oEvent) {
		 
			// get a handle on the global XAppNav service
			var oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation"); 
			oCrossAppNavigator.isIntentSupported(["employeeId-display"])
				.done(function(aResponses) {

				})
				.fail(function() {
					new sap.m.MessageToast("Provide corresponding intent to navigate");
				});
			// generate the Hash to display a employee Id
			var hash = (oCrossAppNavigator && oCrossAppNavigator.hrefForExternal({
				target: {
					semanticObject: "employeeId",
					action: "display"
				}
			})) || ""; 
			//Generate a  URL for the second application
			var url = window.location.href.split('#')[0] + hash; 
			//Navigate to second app
			sap.m.URLHelper.redirect(url, true); 
		}

Deploy the apps to Fiori cloud platform by selecting our intent while registering to Fiori launchpad as follows:

Now when you try to navigate from application1 ( app1 ) to application ( app2 ) in the Fiori launchpad by hitting get employee Id button.

you will encounter the following issues:

  •  Failed to resolve navigation target: “#employee-display” –  sap.ushell.renderers.fiori2.Shell.controller.
  • Could not open app. Please try again later.

This is because the conflict between the semantic object name specified in SAP UI5 application and semantic object name in Fiori launchpad.

Change the semantic object name and action in the SAP UI5 application controller as specified in Fiori launchpad.

oCrossAppNavigator.isIntentSupported([“app2-Display“])
.done(function(aResponses) {

})
.fail(function() {
new sap.m.MessageToast(“Provide corresponding intent to navigate”);
});
// generate the Hash to display a employee Id
var hash = (oCrossAppNavigator && oCrossAppNavigator.hrefForExternal({
target: {
semanticObject: “app2”,
action: “Display”
},
params: {
“EmpId”: emp
}
})) || “”;

Now you will navigate to the URL obtained in the app1 which is to our app2.

Hope its useful!!

Thank you 🙂

 

Assigned Tags

      22 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Vladimir Balko
      Vladimir Balko

      Hello,

      Thank you for the nice blog. Is it functional only for HCP platform or it will work also on premise in the local launchpad?

      Author's profile photo Sri Divya
      Sri Divya
      Blog Post Author

      Hi Vladimir Balko,

      It is not only functional for HCP but also for local launchpad..!!

       

      Thank you!! 🙂

      Author's profile photo Former Member
      Former Member

      Hi Sri Divya,

      Nice blog.

      One question though – what is the use of configuring the semantic object and action in “Navigation” tab in “manifest.json” file of app2, when the same is configured while registering app2 to launchpad.

      Thanks,

      Indrajit

      Author's profile photo Sri Divya
      Sri Divya
      Blog Post Author

      Hi Indrajit,

      Here I have selected the semantic object which I have created in SAPUI5 application to enable navigation in the Fiori launchpad.

      Thank you,

      Sri Divya.

       

      Author's profile photo Pradeep V
      Pradeep V

      Hi Divya,

      Thank you so much for sharing the knowledge, and I am trying to do the cross app navigation, and it worked in IE, but when i try to open the same in Chrome, it does not work, is there any configuration required for chrome to do so?

      thank you in advance.

       

      Regards,

      Pradeep

      Author's profile photo Sri Divya
      Sri Divya
      Blog Post Author

      Hi Pradeep,

      I haven't done any configuration specific to  Chrome. Could you please share the screen shot of your issue?

      Regards,

      Sri Divya

      Author's profile photo Former Member
      Former Member

      ​Hi Sri Divya,

      I have a similar requirement as you mentioned in your blog. I believe your application is doing Cross App navigation.

      My requirement is I want to create a reusable Module or an Application or a Library(whichever is possible to be consumed from Fiorri Launchpad). I want to create a Module which can be integrated or plugged in by any Consuming Application deployed on FLP. I want to display the content of my module within the consuming application which is deployed in FLP.

      I tried to do it using it Library . I am able to access and use the Library from Consuming application from HCP. However I cant achieve this in FLP. When I run the consuming Application which internally uses my Library, it gives me some error.

      Can you suggest me some approach how to do it .

      Thanks for your help.

       

      Author's profile photo Sri Divya
      Sri Divya
      Blog Post Author

      Hi Former Member,

       

      May I know what is the issue you are getting??

       

      Thank you,

      Sri Divya.

       

       

      Author's profile photo Soumyadeep Dasgupta
      Soumyadeep Dasgupta

      Hi Sri  Divya,

       

      I need to navigate from my custom fiori app to a KPI drilldown, could you suggest the configguration i need to do .

      Author's profile photo Sri Divya
      Sri Divya
      Blog Post Author

      Hi Soumyadeep,

      apologize for the late reply. Are you done with you requirement?

      We can achieve this task by following above steps by navigating to KPI drill down using semantic object or by using URL based navigation.

      Thank you,

      Sri Divya.

      Author's profile photo ABDUL KAREEM
      ABDUL KAREEM

      .

      Author's profile photo Mudit Madhogaria
      Mudit Madhogaria

      Nice blog ?

      Is this applicable if I want to navigate from one app to another fiori app in another launchpad?

      The domain name should be same right or can be different?

       

      Thanks

      Mudit

      Author's profile photo Sri Divya
      Sri Divya
      Blog Post Author

      Hi Mudit,

      Good day.

      Yes,it's applicable for cross app navigation in FLP. Yes the domain name should be same to avoid cross-domain issues for security reasons.

      Thank you,

      Sri Divya

      Author's profile photo Swathy M Nair
      Swathy M Nair

      Hi,

      Could you please explain how to read the parameters which we are passing from application 1  to application 2.The same code we used and the navigation is working properly but not able to retrieve the parameter.

      Can you suggest me some approach how to do it .

      Thanks for your help.

      Swathy M Nair

      Author's profile photo Sri Divya
      Sri Divya
      Blog Post Author

      Hi Swathy,

      Hope you’re doing good.

      Sorry for the late reply. Have tried retrieving the startup parameters as below? If not please try and let me know if you have any concerns.

      this.getMyComponent().getComponentData().startupParameters;

      Thank you,

      Sri Divya.

      Author's profile photo Swathy M Nair
      Swathy M Nair
      How to navigate from an existing Fiori App to another  App that is not registered in Fiori Launchpad.
      Author's profile photo Sri Divya
      Sri Divya
      Blog Post Author

      Hi Swathy,

      Sorry for the late reply.

      we can go for URL based navigation in this scenario.

      Hope it helps. 🙂

      Thank you,

      Sri Divya.

      Author's profile photo Eldwin Cheung
      Eldwin Cheung

      This method works fine as of time of writing! For those that may be getting errors, ensure that the word display is capitalized in both fields she mentioned to change.

      action: “Display”
      

       

       

      Author's profile photo Eldwin Cheung
      Eldwin Cheung

      I do have a question, here is my scenario: I have app1 and app2. app1 is a table, upon row press i want to navigate to app2 and pass the event object to app2 so i can bind and display the press'ed object's data. is this possible with cross-app navigation? would it work with a normal route matched handler implementation?

      Author's profile photo Sri Divya
      Sri Divya
      Blog Post Author

      Hi Eldwin,

      Hope you are doing good,

      No it won’t work with normal route matched.

      Before passing the startup parameters please consider the following points as suggested by SAP.

      • The startup parameters are part of the URL and stored in the browser history. This may be a security or data protection issue. If you pass security-critical content, use an anonymized format and keep the sensitive data within your back end application.
      • The length of a browser URL is limited and truncation may occur. Keep the length of the URL fragment below 512 characters.
      • Multi-valued parameters are discouraged.

      Hope it’s useful. 🙂

      Thank you,

      Sri Divya.

      Author's profile photo Sunil Singh
      Sunil Singh

      Hi Divya,

       

      Nice blog easy to understand.

       

       

      Author's profile photo Sri Divya
      Sri Divya
      Blog Post Author

      Thank you Sunil 🙂