cancel
Showing results for 
Search instead for 
Did you mean: 

Fiori In App State issue Appstatekey missing when navigating back

GowthamRaja
Participant
0 Kudos

Hi Experts,

I need to navigate another fiori app APP B in same window from my APP A. So i am enabling in app state, before navigating to APP B i have placed the app state key but when navigating to APP A back in the url the app state key is not available or missing, so my APP A state is empty.

this is my manifest.json routes.

	"routes": [
				{
					"name": "RouteFTO",
					"pattern": "RouteFTO:?query:",
					"target": [
						"TargetFTO"
					]
				},<br>

I dont know why the app state key is missing when navigating back.

One more doubt: I am enabling in app state in my custom freestyle ui5. i am not using fiori elements.

Will in app state work only when we use fiori elements?

Please help.

Thanks,

Gowtham

Accepted Solutions (1)

Accepted Solutions (1)

GowthamRaja
Participant
0 Kudos

@ alexnecula Thanks for your response. The issue has been resolved with the below approach.

My issue is the app state key was missing when coming back from APP B to APP A.

I have added below,

FLP Designer-> TargetMapping-> added parameter -> sap-keep-alive as 'true'

Then in my manifest i have added the optional query paramter as ":?sap-iapp-state:" in the route pattern.

In controller i have done the code set the hash with app state key and passed when doing cross app navigation as below

// create a new Application state (oAppState) for this Application instance
				var oAppState = sap.ushell.Container
					.getService("CrossApplicationNavigation")
					.createEmptyAppState(this.getOwnerComponent());
				
				oAppState.save();

				// Update the URL hash with the key
				var oHashChanger = sap.ui.core.routing.HashChanger.getInstance();
				var sOldHash = oHashChanger.getHash();
				var sNewHash = sOldHash + "?" + "sap-iapp-state=" + oAppState.getKey();
				oHashChanger.replaceHash(sNewHash);
	var oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");
								var hash = (oCrossAppNavigator && oCrossAppNavigator.hrefForExternal({
									target: {
										semanticObject: "MaterialBOM",
										action: "openBOMReport"
									},
									params: {
										"S_EQUIP-LOW": receivedEquipment
									},
									appStateKey: oAppState.getKey()
								})) || ""; 

								oCrossAppNavigator.toExternal({
									target: {
										shellHash: hash
									}
								}); // navigate in same window

I have not done any code to save the data in model. It is now working fine

Answers (1)

Answers (1)

AlexNecula
Active Contributor
0 Kudos