Notify vs NotifyWidge

Notify vs NotifyWidge

My company recently upgraded to Bali. One of my team members noticed the depreciated NotifyWidget action and replaced it with Notify. After that, we had some weird functionality. We use Web Blocks frequently to reuse code.

We have a number of instances where there are nested web blocks inside web blocks. With the old NotifyWidget action we could have a web block call another web block and 'store' the returned information in a local variable, then on a button press, do something with the stored data.

With the new Notify action, when we try to do something with the stored data, we were getting an error message (one we added to make sure the user was actually entering something). When we ran the debugger, the call to the most nested web block ran as expected and returned a message to the web block calling it. Even though the debugger showed that the data was stored in a local variable, when the button was clicked to process the data, there was nothing in the variable.

Is this expected behavior for the new Notify action?

I know this post is rather confusing. So, I attached an eSpace to hopefully make it more understandable.
Hi Jonathan,

If the debugger shows the data arriving in the expected manner, and that data is stored in the local variable, you can be sure the Notify is not where the problem lies. I have seen problems before with storing data inside web blocks though, especially with local variables getting reset. I unfortunately can't remember what the cause was.

I wouldn't have thought the Notify action would cause the problem, but that is the only thing that is different from when it worked as I expected and when it doesn't. That is why I created the eSpace I attached. There are two sets of web blocks that have the same functionality and the same code, but one uses Notify and one uses NotifyWidget. The one set that uses NotifyWidget stores the data in a local variable and it can be retrieved, the data cannot be retrieved in the one that uses Notify.
Hi Jonathan,

Unfortunately I don't see the attachment. Could you check please?
Here is the OML again.
For me they both say "Webblock X has no value stored". Only when I change the buttons from Submit to Ajax Submit, Webblocks 3 and 4 work, but 1 and 2 won't. Intriguing. I'm gonna try to check some more...
As an aside, I asked Support a while back about the differences between Notify and NotifyWidget(_Deprecated). They linked to this page, that says:

"The new Notify action executes the On Notify handler synchronously in the same request. This avoids the need for extra round trips from the browser to the server. As a consequence, the On Notify handler is now executed inside the same transaction and request context as the original caller."

After I enquired some more, they also sent this rather cryptic reply:

"The answer to your question is it depends. As the thread in the link of my previous communication explains, the new Notify action executes everything in the same transaction unlike the NotifyWidget_Deprecated. For instance, if in your OnNotify event it has some database operations, the result of doing that in one only transaction, rather than in simultaneous transactions, might be different."

So there are differences, in that it is synchronous (Notify) vs. asynchronous (NotifyWidget). Why that would, or would not, save the variable stored in memory, I don't know (yet).
Ok, I did some debugging and looked at the source, and the problem seems to be with ViewState. I'm not knowledgeable about the platform to determine what exactly goes on, but it seems that the variable that holds the contents is stored in the view state. With NotifyWidget, this is the view state of the receiving web block, but it seems with Notify, it's the view state of the other web block, causing the problems. (Note that a quick test also shows that retreiving from the web blocks view state goes well, but storing to it does not.)

I assume this is a bug. Do you have a support contract with OutSystems? If so, you can send it to them directly, if not I'd be more than willing to submit this issue to them. Let me know.
Except for the distinctions that Kilian pointed out in bold, there should be no difference in behavior between both. The synchronous Notify should update all the data that was modified, just as the deprecated version.

As Kilian pointed out, the data of the outer block is not being updated in this scenario (and that's a bug), but you can confirm that if the outer block refreshes itself (by adding an Ajax Refresh after the Feedback Message), the Local Variable has its value updated. Note that no extra requests are made by adding the refresh.

Does that workaround work for your real scenarios?

Hi Paulo,

It's great to have confirmed from OS that it's a bug. Is there any planning on when this bug will be fixed?
Hi Kilian,

I'll make sure it is added to our maintenance backlog, but as of now we don't have a planned version for the fix. If this has high impact for you, please report it via Support so that it can be prioritized accordingly.

Kilian - Thank you for digging into this. I really appreciate the thoroughness of the information.

Paulo - Thank you you for the confirmation. I will be discussing this with my team to determin if we will need to submit to Support.

Thanks again for the great information.