updating 'selected' attribute in list generated from SQL query

I have built a simple query (could not use aggregate) to return a list of records along with a column called 'selected' which is either 0 or 1 (MS SQL bit type).  Query runs fine with inputs and properly outputs data to specified structure.

Where I'm struggling is I don't seem to be able to update the 'selected' attribute in the output.  I'm using it as a list source and though the list looks as though it's behaving properly, the attribute 'selected' does not get updated when an entry is either added to or removed from the list.  I use this pattern many other places with normal aggregates with no issue.  I made the assumption it would work the same with output from a SQL query.

I'm left with no other explanation for this odd behavior other than SQL query output objects cannot have their attributes updated.

Hoping this is simple question to answer.  If they are able to be updated then it's something else in my code.

Many Thanks.

Scott

Hi Scott, 

The SQL Tool output is a List, exactly like the one in the output of an Aggregate. There is no difference between them. 

However, you need to remember that the platform is optimized. This means that if you have an boolean attribute that you are updating in the logic, but is not using it anywhere else, the platform detects this and will not keep the information stored in the page viewstate, giving the impression you 'can't' update it, what is not correct. 

If you use the value somewhere, the platform will detect it and you will see that changes to it will become Persistent between requests in the same page (data will be stored in the Viewstate). 

By your description, I am not seeing any other reason. 

Hope this helps. 

Cheers. 

Eduardo,

Thank you, sir, for your fast reply.

Per your email, I do use the boolean attribute in the 'Save' action of the form which is to say it is here that I write the "selected" values into a table.  I'm thinking somehow this is not getting detected which is why I'm losing those values in the viewstate.

How do I learn more about the viewstate?  Any links would be appreciated.  I think you're on to something, I just am not sure I understand it well enough to resolve.

Again, your time is appreciated.  I'm a newb to Outsystems but learning quickly.  Super excited about the platform.

Scott

Hi Scott, 

Please, if you can, provide your OML so we can take a look. This way we will be able to help you without guessing... ;) 

just download the OML (module) and attach to a message here in the thread. 

If you can't because of company polices, please, create a small module that reproduces the problem. 

Cheers 

Solution

Eduardo,

I'm happy to say I figured out my problem and it was me (shocker)!

In the Save action I was cycling the return list from the SQL query looking for items the user "selected" and not the Tags.List which is where the 'selected' flag actually gets updated.  True, rookie mistake but good learning experience.  Hope this might save someone else time in future.

With all that said I read up on viewstate which you recommended and it was both interesting and insightful.  I learned several things I did not know prior so thank you.

Kindly,

Scott

Solution

Eduardo Jauch wrote:

Hi Scott, 

Please, if you can, provide your OML so we can take a look. This way we will be able to help you without guessing... ;) 

just download the OML (module) and attach to a message here in the thread. 

If you can't because of company polices, please, create a small module that reproduces the problem. 

Cheers 

Eduardo,

I marked your last reply as solution hoping to give you credit for helping me.  Is this proper protocol or does 'Mark as Solution' not have anything to do with credit for solution provider?  Just wanting to play by the rules and understand how the forums work.

Thanks,

Scott


Hi Scott,

I usually mark the answer that solves the problem. :)
In this case, even if I "helped", you found the solution by yourself and so, I am marking it as the final solution (as this will help others, hopefully).

Cheers!