When a model is loaded for the first time it can be set to create a new record if no records match the criteria. I have a situation where I am re-querying a record and after that re-query I would like to create a new row if the model is empty. What is the best way to accomplish this.
How about a model action that creates a new row on requery?
The challenge I am running into is I only want one row in the model. Either the row it returns or the blank one if empty. I went ahead and added the new row on requery and now if the model query returns blank it works perfectly in that I see the blank fields and can enter a new value. The problem is if there is already a match then I see the matched record and then I see the blank record pop up which I don’t want. Are there conditions available for actions like there is for rendering or some clever way to only run a particular action if a model has 0 rows for example.
I assume that the model “Create default row if Model has none” option only applies to the first query.
I think Irvin’s solution is your only option to get exactly what you want. You can probably get 90% of the way there by requiring the user press a button to add a new row. Likely not a huge difference in the work flow.
Thank you Raymond and Irvin. For the short term I am going to go with adding the button to the work flow and rendering it when there are 0 rows which I agree should do the trick.