Set "Having" with JavaScript?

  • 1
  • Question
  • Updated 2 years ago
  • Answered
Does anyone know how I would set "Having" (as described in the following community post) via JavaScript Snippet? I would like to create a table filter based on Having.
Thanks!
https://community.skuid.com/skuid/top...
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
"Havings" / "Post-Aggregation Conditions" can be set via JavaScript using the same API's that are used for setting "Pre-Aggregation Conditions": getConditionByName( ) and setCondition( ). getConditionByName( ) will search through both Pre- and Post- Aggregation Conditions when searching for name matches, and setCondition( ) works on either Pre- or Post- Aggregation Conditions.

For instance, if you have an Aggregate Model named "AggData" with a "Having" Condition named "recordCount", you can set the value of this Condition from JavaScript like this:

var model = skuid.$M("AggData");
var recordCountCondition = model.getConditionByName("recordCount");
model.setCondition(recordCountCondition, 42);
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Zach To the Rescue! I Always appreciate everyone's help. Thanks!
Photo of Chandra V

Chandra V, Champion

  • 6,966 Points 5k badge 2x thumb
Just wanted to say Thanks for this also.  We implemented 'Havings' on our community Skuid page to expose our available inventory.  One of our filters is on quantity, and we needed that post aggregation condition on our model to sum the inventory quantities together and the return results.  Used a JS snippet to set the condition and return the results.  Good stuff.