How to make Reactive Web OutsystemsUI device detection work

Referring to this previous question

I am trying to use these device detection client actions from OutsystemsUI in a reactive web app, but they do not return a value. I am putting "" into the UserAgent parameter, because I have no clue what else to input.

I have OutSystemsUI version 2.5.8

Hi Hubert,

To get the UserAgent value we do have a pre-defined function called GetUserAgent() available under Environment directory

GetOS(GetUserAgent())

Also check out the below mentioned OutSystemsUI Module/Environment client actions/functions as well for the mentioned use-case..

Hope this helps you!


Regards,

Benjith Sam

Benjith Sam wrote:

Hi Hubert,

To get the UserAgent value we do have a pre-defined function called GetUserAgent() available under Environment directory

GetOS(GetUserAgent())

Also check out the below mentioned OutSystemsUI Module/Environment client actions/functions as well for the mentioned use-case..

Hope this helps you!


Regards,

Benjith Sam

 Hi Benjith, thank you for your reply, however this doesn't work in my application. The result of GetOs(GetUserAgent()) or using the client actions with the same input, outputs an empty string.

GetUserAgent() on its own works and outputs this for example: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36"

GetBrowser() doesn't work either.

As said in my original post, the application I am building is reactive web.

 

Solution

Hi Hubert,

If you try to open the OutSystemsUI clone module to understand the underlying defined code for these client actions/function, you will observe that it only includes a Switch Case node with multiple conditional branches of which the branch condition reference the input UserAgent value in the index() function to check and assign the Browser and OS types as an output parameter value.

Note: The Index function is defined with hard coded search value which is in LowerCase and in actual the GetUserAgent() function is returning the value in normal case i.e. Chrome


Solution: Wrap the GetUserAgent() with ToLower() function as shown below

GetOS(ToLower(GetUserAgent()))

GetBrowser(ToLower(GetUserAgent()))


Hope this helps you!


Regards,

Benjith Sam

Solution

Benjith Sam wrote:

Hi Hubert,

If you try to open the OutSystemsUI clone module to understand the underlying defined code for these client actions/function, you will observe that it only includes a Switch Case node with multiple conditional branches of which the branch condition reference the input UserAgent value in the index() function to check and assign the Browser and OS types as an output parameter value.

Note: The Index function is defined with hard coded search value which is in LowerCase and in actual the GetUserAgent() function is returning the value in normal case i.e. Chrome


Solution: Wrap the GetUserAgent() with ToLower() function as shown below

GetOS(ToLower(GetUserAgent()))

GetBrowser(ToLower(GetUserAgent()))


Hope this helps you!


Regards,

Benjith Sam

 Brilliant! That works. Thanks Benjith.

 

Hubert wrote:

Brilliant! That works. Thanks Benjith.

You're welcome, Hubert :)


Regards,

Benjith Sam