on 08-18-2023 6:25 AM
Hello,
I have a custom freestyle app in fiori launchpad on S4HANA on-premise. Sometimes, it will be opened via notifications with a parameter.
The issue is that the framework doesn't recognize it.
The pattern on the route is ":?query:".
Example: SemanticObject-action?Id=123456 doesn't work. In the routeMatched event, the ?query argument is undefined.
However, SemanticObject-action&/?Id=123456 works perfectly fine. Unfortunately, I don't think I can add this from the notification.
Is it possible to do something about this? I have tried using window.location to extract the id then replace the URL to get rid of it. However, when I navigate to the next page where I use the ID, the URL is changed again to add that parameter.
Thanks,
Alex
I ended up getting the parameter I needed via regex on window.location.href then redirecting to the correct URL (with &/ before the parameter). Not the most elegant solution but it works. Hopefully SAP will fix this issue in the future.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello, i used to use the following code to extract URL parameters. Also check the "NavigationHandler", which may be a more seasoned approach.
decodeURLparameters: function() {
//
// in order to get all parts of the url we need to split the following characters:
//
// # - to separate possible #navigation parts
// ? - to separate queries.
//
// we may have more ore non of them.
//
var obj = {};
var urlChunks = [];
//
// separation of # tags
//
var parts = decodeURIComponent(window.location.href).split("#");
//
// for each entry we further need to split by '?'
//
for ( var k = 0; k < parts.length; k++ ) {
var queryChunk = parts[k].split("?");
//
// now split the query into query parameters
//
for ( var x = 0; x < queryChunk.length; x++ ) {
var queryParams = queryChunk[x].split("&");
//
// now process the param
//
for ( var y = 0; y < queryParams.length; y++ ) {
var subParts = queryParams[y].split("=");
if ( subParts.length === 2 ) {
var key = subParts[0].toLowerCase();
obj[ key ] = decodeURIComponent(subParts[1]);
}
}
}
}
this._urlParams = obj;
},
/* out of context examples, please search */
sap/ui/generic/app/navigation/service/NavigationHandler
...
let navHandler = new NavigationHandler( this ); // in component.js
...
let parseNavigation = navHandler.parseNavigation();
...
parseNavigation.done( ... )
Ge.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.