cancel
Showing results for 
Search instead for 
Did you mean: 

How to get URL parameters in SAP Screen Personas

awguthrie
Participant
0 Kudos
380

Greetings,

How do I access the URL parameters inside the Screen Personas flavor?

The goal is to call a flavor by the URL while including some additional values as parameters.

The parameters come back empty when using plain JavaScript, and I don't see any references to the URL parameters from any of the Screen Personas scripting objects.

Personas version 3.17

I saw this thread, but found no solution:
https://community.sap.com/t5/technology-q-a/how-to-access-browser-url-parameters-in-personas-flavor-...

awguthrie_0-1726607674375.png

Thank you

View Entire Topic
vananko
Product and Topic Expert
Product and Topic Expert
0 Kudos

Yes,

SAP Screen Personas scripting doesn't have any objects to operate with URL. 
BUT you can use Javascript and window object to retrieve needed parameter. 

Try this:

/* globals console, window, URLSearchParams */
const params = new URLSearchParams(window.location.search);
console.log(params.get('sap-theme'));

If this doesn't work for you, search similar solution.

Best Regards!

awguthrie
Participant
0 Kudos

Thank you for the reply. This doesn't seem to work, the problem is that it comes back empty:

awguthrie_0-1726843418784.pngawguthrie_1-1726843425602.png

 

vananko
Product and Topic Expert
Product and Topic Expert
0 Kudos

For me similar URL works. So just check what happens with "window.location", then "window.location.search" and so on.

Maybe you are using not supported browser.

There is an example:

get_param.png

awguthrie
Participant
0 Kudos

Thanks for that screenshot. I've tested with the latest version of Chrome and Edge, so not sure what is happening. For comparison, I created a basic HTML file with the JavaScript and it worked successfully, the parameters are fully visible. On the Personas page, the window.location.href string ends with 'personas#'.

awguthrie_0-1727107300111.png

 

awguthrie
Participant
0 Kudos
Can you tell me what version of Personas are you using in that screenshot?
vananko
Product and Topic Expert
Product and Topic Expert
0 Kudos
This example is pure javascript and related to browser features. This shouldn't depend on Personas version. If there is a url address with provided url parameter, then it should work. When you have "https://.../sap/bc/personas" only, then there are no parameters to get.