How do you combine data.length for different models in a tab?

  • 1
  • Question
  • Updated 2 years ago
  • Answered
I have a tab that has three tables with all of the same object (Cases), but different models to separate them. How do I get a total of all cases to show in the tab to let the user know there are records present? I know how to get the count for one model, but I can't figure out how to get the sum.

Thanks!
Photo of Andrew Hess

Andrew Hess

  • 262 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Short of using javascript, I'd create another model just for this purpose. That model have three conditions that with the following logic. 1 OR 2 OR 3
Each condition would be Id "in" field model of another model field Id.
Photo of Andrew Hess

Andrew Hess

  • 262 Points 250 badge 2x thumb
Thanks for that answer. The conditions have changed on my end, though.

Is it possible to get an aggregate count of records from three different objects?
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
No,  it is not possible to aggregate data from multiple sObjects. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Digging for another answer and I see this question.  Things have changed!

Make a UI only field that aggregates the length of each model together.  Something like this. 

{{$Model.myModel1.data.length}}+{{$Model.myModel2.data.length}}

That should get you your aggregated value to put in a tab...