I created an update named query and execute it in the script using system.db. runNamedQuery.
The function call always throws an error: The query did not return a result set.
But the manipulations in the data base work. The function obviously just has problems writting the result (in this case it should be the amoung ot the affected rows).
When I catch the error in the script, everything wokrs without issues, but I don't see the result in the view - I have to change something on the page or to set the data polling to 1 second or something to see the result of what my script does.
Refreshing the page via script at the end also doesn't change anything on the situation.
But that's the solution, though. So if it doesn't work, it means you missed something somewhere... and we can't help with that if you don't tell us what you did and what didn't work.
Perspective.
I have a table with some data between two dates, which I can choose. I can select a row from that table and send the data from that row to another system using a button I created. In the table there is a column telling me, how many times I already sent the data from a certain row to the other system. At the end of the sending process I run an update query and add 1 to the number in that field. The query makes the updates I want, but throws me an error message: The query didn't give any result.
If I catch this error in the script, everything works fine, only I dont see any result, unless I do something on the page (like choosing a different date) or set the polling on the table to a small number.
Example:
There's 2 in the field, I press the button, the query is run: I still see the 2.
In my data base in the same line I see 3, which is the expected result.
I refresh the page manually and only then I can see that 2 changed to 3.
Your suggested solution with adding refreshBinding at the end of the script behind the button did not change anything.
We might need to see some screenshots and code snips that demonstrate what you are doing.
@Priyanka.Khandge is correct... the refreshBinding is the proper way to refresh a binding in Perspective, but without knowing which object has which it is hard to point you in the correct direction.
This one just adds 1 to a certain field.
It also gives me an error saying that the query did not return a result.
But at the same time I see in the data base, that the the data are changed and the query actually did; what it was supposed to do.
NB: ast.literal_eval is a performance nightmare. It's unlikely you need it at all, but you can likely replace it with the dict() builtin for the same end result with much better performance.
Well.. I'm guessing your script is executed from a button. So, that means self is the button.
You're trying to refresh the custom.settings property on the button itself... Which I doubt is what you actually want to do.
You need to use .refreshBinding on the component that has the binding.
I was gonna say... It's not the first time I see ast used for things that have nothing to do with actual ASTs. Where do people even find that idea ?