Mobile App How to Get Current Screen

Mobile App How to Get Current Screen

  

I was interested in making the Bottom Bar show different content, depending on which screen of the mobile app is currently being viewed. I used an IF statement to get different output depending on the content of the GetBookmarkableURL() function.


When previwing in a browser, this works as the URL is fully populated:

https://myenvironment.outsystemscloud.com/ModuleName/PrivacyPolicy

However, when viewing in the Outsystems Now app, this URL finishes at the ModuleName, and I am unable to get the current page.

https://myenvironment.outsystemscloud.com/ModuleName/


Does anyone know how to get the current page being viewed?

Hello Russell,

While the documentation does not explicitely says something, in fact this function does not work as expected (according the documentation).

A possible workaround is to include an input parameter in the block and set it in each page... (like we do with menus in Web).

Don't know if there is another way to "know" (automatically), in wich page you are...

Eduardo Jauch wrote:

Hello Russell,

While the documentation does not explicitely says something, in fact this function does not work as expected (according the documentation).

A possible workaround is to include an input parameter in the block and set it in each page... (like we do with menus in Web).

Don't know if there is another way to "know" (automatically), in wich page you are...

Thanks Eduardo. I have created an Input Parameter of CurrentPage in my Bottom Bar block, and in my Privacy Policy Page I have created a Local variable called ThisPage. In the Onready event I create an Assign action and set ThisPage to "Privacy" but I cannot seem to see the ThisPage variable from the BottomBar block as it is out of scope. have I missed something else here?


Solution

Russell Codd wrote:

I was interested in making the Bottom Bar show different content, depending on which screen of the mobile app is currently being viewed. I used an IF statement to get different output depending on the content of the GetBookmarkableURL() function.


When previwing in a browser, this works as the URL is fully populated:

https://myenvironment.outsystemscloud.com/ModuleName/PrivacyPolicy

However, when viewing in the Outsystems Now app, this URL finishes at the ModuleName, and I am unable to get the current page.

https://myenvironment.outsystemscloud.com/ModuleName/


Does anyone know how to get the current page being viewed?

Hi Russell,


From what I could see, either on browser (Chrome) or via Outsystems Now or the app itself, the function is working correctly on my end, aside from the initial screen. 

When you first access the app via mobile (Outsystems Now or .apk), the URL is presented without the page but after that the function GetBookmarkableURL() works as expected, when you navigate from screen to screen.

Tell me if you are still encountering this issue.


Best regards,

Davide Résio


Solution

Davide Résio wrote:

Russell Codd wrote:

I was interested in making the Bottom Bar show different content, depending on which screen of the mobile app is currently being viewed. I used an IF statement to get different output depending on the content of the GetBookmarkableURL() function.


When previwing in a browser, this works as the URL is fully populated:

https://myenvironment.outsystemscloud.com/ModuleName/PrivacyPolicy

However, when viewing in the Outsystems Now app, this URL finishes at the ModuleName, and I am unable to get the current page.

https://myenvironment.outsystemscloud.com/ModuleName/


Does anyone know how to get the current page being viewed?

Hi Russell,


From what I could see, either on browser (Chrome) or via Outsystems Now or the app itself, the function is working correctly on my end, aside from the initial screen. 

When you first access the app via mobile (Outsystems Now or .apk), the URL is presented without the page but after that the function GetBookmarkableURL() works as expected, when you navigate from screen to screen.

Tell me if you are still encountering this issue.


Best regards,

Davide Résio


In Chrome it works on HomePage also.

Indeed, in mobile, it retrieves the page name only in "no home page" pages.

@Russel,

Variables in a page are not visible inside the block, and vice-versa. Is that you are running it? Anyway, you can use the GetBookmarkableURL() as it will retrieve pages URL if not the home page, like Davide pointed.


Thank you Eduardo and Davide.

I had my Privacy policy set to be the home screen, so GetBookmarkableURL was indeed not showing the 'name' of the page. After I changed my Default Screen in OutSystems Studio to another screen, the Privacy policy page does show its name at the end of the URL.

It seems that I can work around this by expecting the Home Screen to not show a named URL (only root), and other pages will work as expected, showing the folder/screen name at the end.

Thank you both for helping me to understand this.

Hi Russell,


You can retrieve the actual screen name, without the input parameters, like so:


Function "GetURLPageIndex" with output parameter "URLPageIndex" = 

SyntaxEditor Code Snippet

Index(GetBookmarkableURL(), GetOwnerURLPath()) + Length(GetOwnerURLPath())


Function "GetURLPageLength" with output parameter "URLPageLength" = 

SyntaxEditor Code Snippet

If(Index(GetBookmarkableURL(), "?") <> -1, Index(GetBookmarkableURL(), "?") - GetURLPageIndex(), Length(GetBookmarkableURL()) - GetURLPageIndex())


Function "GetURLPageName" with output parameter "URLPageName" = 

SyntaxEditor Code Snippet

Substr(GetBookmarkableURL(), GetURLPageIndex(), GetURLPageLength())


There might be a better way to address this issue but with this you can retrieve the screen name using only Outsystems' "default" functions. Also, you can set the names of the aforementioned functions and parameters as you like, those are just an example.


Let me know if this helps.


Best regards,

Davide Résio