cancel
Showing results for 
Search instead for 
Did you mean: 

App State Saving Issue - CrossApplicationNavigation Error(403) in Service INTEROP

selenzser
Explorer
0 Kudos

Hello,

I tried to implement the App State Saving feature as described in this Guide:

https://blogs.sap.com/2017/09/15/how-to-enable-the-share-option-and-persist-current-application-stat...

But when I try to save the new state of the App with the code shown at the end of this post I will get an 403
error in Service /sap/opu/odata/UI2/INTEROP/GlobalContainers. It says that the CSRF-Token Validation failed.

So in the comments somone suggested to turn on option ‘Save App State Data’ under Fiori Launchpad Administrator Page -> Settings -> System Settings.

But I cannot find these Settings anywhere in transaction /UI2/FLPD_CUST.

So can please anyone help me finding these Settings to persist the current application state in the INTEROP service?

Any help is appreciated and please let me now if you need further information to help me.

	this.oAppStateHref = sap.ushell.Container
					.getService("CrossApplicationNavigation")
					.createEmptyAppState(this.getOwnerComponent());
				this.oAppStateHref.setData(this._oAppState); 
				this.oAppStateHref.save();

selenzser
Explorer
0 Kudos

Here the more detailed coding which was used to do the Job.

Can anyone help me please?


onInit: function () {
	// create an instance of the navigation handler
	this.oNavigationHandler = new NavigationHandler(this);
        this.oLinkHandler = new NavigationPopoverHandler();
						
	this.oAppStateModel = this.getOwnerComponent().getModel("GlobalContainers");	
	this.oHashChanger = sap.ui.core.routing.HashChanger.getInstance(); 
						
	// on back navigation, the previous app state is returned in a Promise
	this.oNavigationHandler
	        .parseNavigation()
		.done(this.onNavigationDone.bind(this));
},
onPressNavigateToMaterial: function (oEvent) {
			
	this.saveAppState();
        var that = this;
        var oSetting = this._getLinkSetting(oEvent.getSource());
			
	this.oLinkHandler.setSemanticObject(oSetting.semanticObject);
	this.oLinkHandler.setFieldName(oSetting.fieldName);
	this.oLinkHandler.setContactAnnotationPath(oSetting.contactAnnotationPath);
        this.oLinkHandler.setControl(oEvent.getSource());
	this.oLinkHandler.setEnableAvailableActionsPersonalization(true);


	this.oLinkHandler.attachBeforePopoverOpens(function (oPopoverOpensEvent) {
	
	   if (oSetting.fieldName === "MATNR") {
	       oPopoverOpensEvent.getParameters().setSemanticAttributes({
		 Material: oPopoverOpensEvent.getParameters().semanticAttributes.MATNR
		                                                        }, 
                 oSetting.semanticObject);
				                                                  }
				
	//set the app state key
	oPopoverOpensEvent.getParameters().setAppStateKey(that.oAppStateHref.getKey()); 
        oPopoverOpensEvent.getParameters().open();

			                   }); //end of attach before popover opens
        this.oLinkHandler.openPopover();
},
saveAppState: function () {
	var oSmartFilterBar = this.getView().byId("smartFilterBar");
	this._oAppState.selectionVariant = oSmartFilterBar.getDataSuiteFormat(); 
				
	//create the appstate
	this.oAppStateHref = sap.ushell.Container
	        .getService("CrossApplicationNavigation")
		.createEmptyAppState(this.getOwnerComponent());
	this.oAppStateHref.setData(this._oAppState); 
	this.oAppStateHref.save();
				
	//change the hash
	var sOldHash = this.oHashChanger.getHash();
	var sNewHash = sOldHash + "?" + "sap-iapp-state=" + this.oAppStateHref.getKey();
	this.oHashChanger.replaceHash(sNewHash);
},
_getLinkSetting: function (oControl) {
	var sControlId = oControl.getId();
			
	//set navigation attributes for Material or PurchasingInfoRecord Link
	if (sControlId.includes("IDMATNRLink")) {
		return {
		        semanticObject: "Material",
			fieldName: "MATNR",
			contactAnnotationPath: "MATNR"
			   };
			                         } 
        else if (sControlId.includes("IDINFNRLink")) {
		return {
			semanticObject: "PurchasingInfoRecord",
			fieldName: "INFNR",
			contactAnnotationPath: "INFNR"
				};
			                              } 
        else {
	MessageBox.error("Control with id " + oControl.getId() + " is not supported.");
	      }
}

Accepted Solutions (0)

Answers (2)

Answers (2)

selenzser
Explorer
0 Kudos

Another thing i found while debugging is that the error is thrown at the popover open event and not on the navigation itself.

rahullohia
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Sebastian,

Did you fix this issue? I am facing the same error and my app state is not preserved. I vividly remember this working fine a few days back but now , even though I get the app state but my FIORI application does not respect it anymore.

Thanks,

Rahul

Joseph_BERTHE
Active Contributor
0 Kudos

Hi,

It is a HTTP 403 which means authorization denied. Did you check that ?

Regards,

Joseph

selenzser
Explorer
0 Kudos

Hey thanks for the hint.

Yes I already checked it and it says that the CSRF-Token Validation failed for the service.

Do i have to transport the CSRF-Token to the target Apllication for the navigation? Didn't see anything like this in Blogposts for app-state saving. Any other (self-developed) OData Request can be executed normally without any token issues.