Front-end not updated after data fetch

Hi,

I have a webscreen that is fetching data from another source. To make it simple I only added two parameters, one for the data and one to point out that there has an error occured. The problem is that the parameter IsDataError is True, but the front-end is not updated and the spinner is still shown. Why is this happening?

I've created a simple example of my problem. The action to fetch the data does not hold any actual logic. It only holds the true state. Because I already checked if the IsDataError gets set and it does.

Bo

Test.oap

Hi Bo,

I did not see a WebBlock in your Test.oap, and in the data action IsDataError was True by default as well, so it was never showing the spinner anyway.

So if we make the variable that detects the error False by default and only make it True after an error is received, then that change in the variable would also change the condition in frontend.

I changed the code a bit, can you check the new oap to see if that's what you're trying to achieve?

Testupdated.oml

This is exactly what I want and I did the exact same thing on my end. The IsDataError is by default on false, but after an error (Which happens after a couple of seconds) the variable will be set to true. But the front-end if-statement won't change and keeps showing the spinner.

I also meant a webscreen instead of webblock.

Are you sure the variable in the If statement is the same variable that is being changed after the error occurs? 

Maybe you are using a local variable in the If but actually changing the value of data action's output parameter after the error.

As far as I can see it is really the parameter of the fetch action. And I debugged it and it showed me that the GetDocumentError gets set to True. The boolean has been kept default so the default value will be False at the start. Which is good and indicates it is loading.

I'm sorry, I'm not sure what else could be the issue. Maybe another piece of code is changing the value of the variable (e.g. OnAfterFetch of the data action?) or there is actually another spinner that you see in the screen.

Either way, I suggest that you show the spinner only by checking the IsDataFetched instead of via GetDocumentError. Because with the current logic, the spinner will be continued to be displayed when there are no errors.

I couldn't find anything in the Test file you provided but by what im reading you're probably missing a boolean variable that takes the opposite value of the one for the DBerror which you need to put in the " is visible " property of the component you're trying to hide.

I also suggest that you use IsDataFetched and HasFetchError properties of the data action while showing a spinner/error message. You can have a look by creating a new screen from a template and see how the platform uses them while fetching data.


That possibly could fix my problem. But it's an alternative. But I'm curious why the front-end is not refreshing the if-statement if the parameter is changed ? To my knowledge it should refresh the front-end if-statement when the parameter changes.

Anyway, If you know the problem why my front-end isn't updating the if-statement please let me know. I will try and use the alternative way.

Thanks

Hello @Bo Menick,

The data action's error output (boolean) needs to be assigned to a screen variable to force the screen to refresh.

I have set a new screen variable IsDataError2 to the output from the data action in the 'OnAfterFetch' event. Please check out the attached oml.

Regards,

AJ

Testv2.oml

Agreed, the only way to get the data action output to the screen's local variable is to use on After Fetch action so that we can assign the data into local variable.

Rethinking about my problem from a couple of days ago. I tried multiple things like using the variable directly in the screen. With a local variable in combination with the OnAfterFetch. But the OnAfterFetch doesn't get triggered. I added an all exceptions in case it would throw an error. But that doesn't seem to be the problem.

Hello @Bo Menick ,

It is hard to tell what's wrong in your code when you state that the OnAfterFetch is not being triggered. There could be factors in play that may not be obvious from the screenshot you shared. 

Is it possible for you to recreate it in an oml if the scenario is any different than the one I attached in my last post?

I've had a similar problem in the same module. I will update the post when I find it.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.