I am trying to conditionally display a view on a SmartForm. The view is connected to a List event of a SmartObject from a SQL database.
I start off with the view set to not visible and then in the form initalization event I want to check if the view has values and then display it if it does.
I tried adding a Count aggregation to the list view and then testing for the value not being = 0. If it is true, then I Show the view. The aggregation comes back correctly but the Condition doesn't evaluate. If I 'Show a message' to the user with the value of the aggregation before doing the test, then it works. If I take the 'Show message' out then it stops working again. I tried putting the condition in the 'Initialized' method instead of Initializing, but that didn't help either.
Can anyone tell me the best way to achieve the desired behaviour please?
I might be wrong, but I think your rendering your view in a way that may cause more overhead.
Can you provide more information on the loading of your view? I will commonly create a New and Exisiting rule event that will either make my controls empty for input or populated wtih the values of my backend data.
You shouldn't need a list view to load data on your controls. You should be able to fire the load event and put in a unique ID related to the row data.
For example, if I have an employee table from sql and it has first, last name, address. If I were to load ID 1 from that table, I'd get back those values so that I can load them into SmartForm controls.
Thanks for the replies. I have attached a screen shot which might make it easier to understand the issue.
The strange thing is that the method using the aggregation works if there is a user interactiion via the message box. So I am wondering if it is a timing issue.
However, if there is a better way, I'd love to understand it.
Actually the screen shot looks different than what I was thinking you were trying to accomplish. Your right on the timing issue, it's hard to evaluate the timing when we can only see the screens.
So the next rule would be a condition to test to see if this control has data. If it has data then Show your view.
Let me know if that does or does not make sense.
thanks for the reply. Yes it makes sense. However I am not looking to see if they are a manager, I am doing a SQL query for all records where the 'Manager' column is equal to the current user network id. I only want a list of records for people that report to the current user.
I am starting off with it hidden and then trying to show it if there are results in that list. But because of the timing issue, it doens't display unless I put the prompt up first.
I am wondering if I am going to have to do another smartobject query against a stored proc to get the number of results in order to decide whether to display the view. It is a bit redundant though and I would prefer not to.
So I have worked out that if I force the view to initialise directly before checking the count value in the aggregation, that it does then work.