Problem with aggregate model conditions using UI only Field

  • 1
  • Question
  • Updated 2 years ago
  • Answered
-Still on Rockaway.
- I have an aggregate model. It has a sum aggregation on number of minutes. This (obviously) totals the number of minutes from all of the records that match the condition criteria of "Last Month".
-This works great, except that I need the model to only load records where the summed minutes are greater than 20.
-I built a UI only formula field that is equal to the sum of minutes aggregation. This works the field displays the correct number in the table.
-The problem is that I then create a condition based on the UI only field that says to only display if the UI only field is greater than 20.
-This condition doesn't work. All records are displayed regardless of minutes.
Any Ideas?
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb

Posted 2 years ago

  • 1
Photo of J.

J., Official Rep

  • 7,470 Points 5k badge 2x thumb
Raymond,

Conditions on Ui-Only fields are only used for setting default values when rows are created at present. However, I think the functionality you are after is presently in Skuid, just only available via XML editing (and only for Salesforce models, by the way). Did you try the "HAVING" approach?
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I have a new tweak to this:
For certain reasons, I have a basic model that has a UI only field which looks up a value on an aggregate model to pull an aggregate sum. This works great. However, if I build a condition in the basic model based on the UI field (which I think I should be able to), the query ignores the condition. I am wondering if it is because, even though the aggregation occurs in a different model, a model condition can't be build on a UI field that uses info from a model aggregation? Would Having work on a basic model?
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I Got it after a lot of trial and error. Seems like an issue with page builder. It wasnt adding the alias name from the aggregate model grouping into the condition parameters. I hacked the the xml and replaced the object field name with the aggregate field alias and it worked. Having, in case you are interested, did not cause an error when I added it to a basic model, but it didn't seem to do anything.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Last question on this: Can you set having through javascript and what would that look like? I would like to be able to create a table filter based on having.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I did not try having. I found this post, which may explain my issue and also a summary of the XML hack required. I'll update this post with my results. Thanks!

https://community.skuid.com/skuid/top...
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Ha! I see we are talking about the same post! I just clicked your link and saw it took me to the same link as the one I found. Thanks, J...... i
Photo of Damien Murray

Damien Murray

  • 474 Points 250 badge 2x thumb
Good luck Raymond, I'm interested to see how you go as I tried aggregating UI only fields in the past with no luck and used javascript to achieve the desired result. 
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Hi Damien,
The solution prescribed in the link in the comments worked for me. I wasn't trying to aggregate A UI field, however. I was trying to filter a table based on an aggregate value and was trying to use a UI field to accomplish that. ultimately I was barking up the wrong tree and what I needed was "Having".
Good luck!
Photo of Damien Murray

Damien Murray

  • 474 Points 250 badge 2x thumb
Thanks for the clarification, still very useful to know.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
IT WORKED! First Try! Thanks J. and Zach. This is hugely useful to me. I have a couple other places I have been using band aids that I can fix with this. Glad I asked the Community!