Calling a Screen Action on Extended Properties (onblur, onfocus, etc)

Calling a Screen Action on Extended Properties (onblur, onfocus, etc)

  

Hello fellow OutSystems friends,


I am currently working on a functionality on an input button's onblur to call a Screen Action (Let's name it OnInputBlur). Here's an example:

Input1: Free text input
Disabled Input2: Generates information from a Screen Action (OnInputBlur) when Input1 loses focus


The question is: As only OnChange is provided for input field, how will I be able to call the Screen Action (OnInputBlur) on the "onblur" of Extended Properties?


Thanks in advance!

Hi Danilo,

On the extended properties you can call (click) an hidden button (display:none;) that will run the screen action you want. Use this javascript: "document.getElementById('"+HiddenButtonName.Id+"').click();"

Hi Tiago,

Thank you for your reply. I have tried this and is working, but is very inefficient especially when I am incorporating a lot of events on 1 input field. I am calling Ajax Refresh on the Screen Actions and sometimes the value that I want is not reflected correctly. Is there any other way to do this?

Actually that is a very good question, which I don't think I've have ever seen responded by OutSystems staff

If you take a close look at what the platform generates automatically when having an onchange set, should be something like:

onchange="OsAjax(arguments[0] || window.event,'the input name here','the input id here','Change','__OSVSTATE,','');"

The input name is the same as the input id but with "$" instead of "_"

You can replicate this behavior by yourself on the onblur property, but I would love to hear a better option to do this

Best regards,

PC

Digging a bit in the P10 documentation we have this link that shows us how to execute a server side action in mobile apps...

Would be awesome to have the same in Web applications

Best regards,

PC

Hi Pedro,

Thank you for your reply. I visited the link you mentioned and indeed it does have the same functionality for the mobile app. I do hope there is an easier (and less cluttered) way in the Desktop app. I'll let you know when I find a solution for my problem, but if there are any other suggestions it is greatly appreciated. Thanks!

@Outsystems Staff

Any comments to this thread? :)

What's the correct approach to use when we need to use screen actions in onblur/onfocus events without having to use an extra click on a hidden button?

Best regards,

PC

Pedro Coelho wrote:

@Outsystems Staff

Any comments to this thread? :)

What's the correct approach to use when we need to use screen actions in onblur/onfocus events without having to use an extra click on a hidden button?

Best regards,

PC


I still need this as well ... I need an OnKeyPress event to call a ScreenAction too.

Was this ever solved?

Solution

@Bruce Buttles

I don't think it ever got an official answer

I did find out a viable option to do this:

  • Add a FakeNotifyWidget (from RichWidgets) to the block and create an OnNotify action for it
  • Name it (the FakeNotifyWidget) and on the onblur event of the desired input add the following:
    OsNotifyWidget('<FakeNotifyWidget>.Id', '<message>')
  • On the OnNotify action you can get the <message> using the NotifyWidgetGetMessage() built-in function and treat it accordingly

Hope this helps

Best regards,

PC

Solution

Pedro Coelho wrote:

@Bruce Buttles

I don't think it ever got an official answer

I did find out a viable option to do this:

  • Add a FakeNotifyWidget (from RichWidgets) to the block and create an OnNotify action for it
  • Name it (the FakeNotifyWidget) and on the onblur event of the desired input add the following:
    OsNotifyWidget('<FakeNotifyWidget>.Id', '<message>')
  • On the OnNotify action you can get the <message> using the NotifyWidgetGetMessage() built-in function and treat it accordingly

Hope this helps

Best regards,

PC

Hey thanks this worked like a champ!


Glad it helped :)

Best regards,

PC