0

Hello,

we are facing an issue with passing optional parameters using routing. Parameters are passed to another view when the app runs on BTP, but not on Prem.

The route is defined as follows:

{
name: "routname",
pattern: "thisisname/{mandaroty1},{mandatory2}/:?optional:",
target: ["targetName"]
}

This is how I navigate:

oRouter.navTo("routname", {
mandatory1: "test",
mandatory2: "test2",
"?optional": {
optional1: "value1",
optional2: "value2"
}
});

In target view: in onInit:

var oRouter = this.getRouter();
oRouter.getRoute("shapeIT").attachPatternMatched(this._onRouteMatched, this);

in _onRouteMatched:

_onRouteMatched: function (oEvent) {
            var oArgs = oEvent ? oEvent.getParameter("arguments") : null;
            console.log(oArgs);
}

In console of the onPrem I see as follows:

{
mandatory1: "test",
mandatory2: "test2",
"?optional": undefined
}

On BTP I see all values.

What do I miss?

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
keshet
  • 1,716
  • 5
  • 27
  • 54
  • With which SAPUI5 version is the app on premise running? You can find it out by pressing [\[Ctrl\]+\[Shift\]+\[Left-Alt\]/\[Left-Option\]+[P\]](https://sdk.openui5.org/nightly/#/topic/616a3ef07f554e20a3adf749c11f64e9%23loio616a3ef07f554e20a3adf749c11f64e9). – Boghyon Hoffmann Oct 01 '22 at 15:17
  • Is the app running in an FLP shell? Is the issue reproducible if it's run standalone without FLP? – Boghyon Hoffmann Oct 01 '22 at 15:20
  • @BoghyonHoffmann, the version is 1.71.48, the app runs in iView of SAP portal, not in FLP. – keshet Oct 02 '22 at 07:01
  • And with which SAPUI5 version is the app running in BTP? Is the app in BTP running without FLP there either? – Boghyon Hoffmann Oct 02 '22 at 20:56
  • @BoghyonHoffmann on BTP it was 1.96, no FLP. – keshet Oct 05 '22 at 20:31
  • Try running the app with SAPUI5 1.71.48 on BTP and let us know if the issue is reproducible there. If not, it's likely an issue with the iView environment. – Boghyon Hoffmann Oct 06 '22 at 07:54
  • @BoghyonHoffmann retested it on BTP, not working there as well. It works from version 1.75. Strange... – keshet Oct 23 '22 at 12:26

1 Answers1

0

You are trying to pass an object in the optional parameter. That's cleaver but I believe the problem is because of that. I would recommend using a JSON.stringify() to convert your optional parameters to a string and convert the string back to a JS object by using JSON.parse() on your _onRouteMatched handler.

fabiopagoti
  • 1,467
  • 14
  • 31