Aggregate table in a drawer- Context Issue

  • 1
  • Question
  • Updated 5 months ago
  • Answered
I am having a hard time showing an aggregate table in a drawer properly. The filters work properly in terms of showing the correct related information. However, when I open two drawers at the same time, the information is merged in both drawers. I have tried adding the context id's for the table but that gives me blank drawers.

I am thinking that something special has to be done since the drawer table is an aggregate model but I have been unable to figure out what that is. 

1 Draw open. All the data shows properly.


2 Drawers open. The information for both records show in both drawers.


The Before load actions seem to be set up properly. When the model is queried it is set to "get more". 
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb

Posted 3 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Is the query set to "Get More' vs "Standard"? You want "Get More".
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
The query is set to "Get More".
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Oh yeah. The Id field context portion is tricky with agg models. You need to make sure the alias for the Id is "Id" and not the default alias name it gives you of "id" which has a  lower case i.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I am. Was to going to suggest that we meet to look at it.

Are you using an aggregate field that is on a related object via lookup/master-detail as the field to set context against?
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
That would have been fantastic! Maybe next year. 

I am using an aggregate field that is on a related object via lookup/master-detail. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
The images at the top seem to show detail records in your drawer,  not aggregations (unless you are using somthing like Max record Id in the aggregatation)

But I've been able to put aggregate models in a drawer. There are a few cues that may trip you up.  
1. The field controlling the context condition applied in the component of the drawer has to be in the aggregate model (and in the primary model).  Here is my case:  Under a list of accounts I have a drawer where contacts are aggregated by department.  Because the account will be used for the context condition it needs to be in the grouping fields as well.

2. If you cannot make the alias match the field name (for whatever reason) the xml code replacement looks like this.

          <condition type="contextrow" field="FieldAliasName" mergefield="Id" operator="="/>
 
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
I now have this working properly! Thank you for all of your help.

Lesson of the week: Don't try to figure something new out when you are juggling 10 other things. The task will feel much more complicated than it actually is.

Rob - what you describe above worked perfectly.

Pat - I can see why you change the alias name to the exact name of the field. It is much easier than having to change the XML.

I think why everything kept failing for me was I kept making changes to the same grouping fields. I would imagine information was being cached so everything I did didn't work. Once I removed all the grouping fields and started over everything worked with out issue. 

Thank you as always!
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Aaah Yes!!  We're all doing a happy dance! 

Photo of Chelsea Curtis

Chelsea Curtis

  • 1,300 Points 1k badge 2x thumb
This has been helpful. I have a similar use case. I have an aggregate table with master classes that have drawers that should show the aggregate of its corresponding sub items. I'm trying to pass the master class, but it's giving me duplicate sub classes within the drawers.



I used Rob's suggestion within the XML. The master class (SPS Class) is grouped with the alias "sPSClassc". The sub class aggregate model has an aggregation MAX(SPS_Class__c) with the same alias "sPSClassc" so I could use this to pass in the context.

I used before load to activate and set the sub class aggregate model to the "sPSClassc", queried, and added context within the XML where Field = "sPSClassc" and Merge Field = "sPSClassc".

When the query is on Standard, it returns the correct sub classes, but obviously you can only click on one at a time. It's only when I switch the query to Get More that it doubles the sub classes...

Any ideas would be much appreciated. Thanks.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Doubling the sub classes is symptom of problems in your context conditions.  They are not being applied which means all rows in the model will show in the open drawer,  not just the ones you want to be connected to the parent.
Context conditions are annoyingly very hard to debug.  

I'd reccomend actually changing the name of one of yoru context alias values.  Sometimes there is confusion when ID's are named the same thing.  I'm not sure that is the case here, but its worth a shot. 
Photo of Chelsea Curtis

Chelsea Curtis

  • 1,300 Points 1k badge 2x thumb
Hi Rob,

The weird part is that not all rows in the model are appearing. It's correctly showing the sub classes of the master class, it just happens to show the correct sub classes twice... That's why it seems like the context is actually working to an extent. 

Why would it show the correct sub classes when I query with Standard, but double when I query with Get More?
Photo of Chelsea Curtis

Chelsea Curtis

  • 1,300 Points 1k badge 2x thumb
Hi Rob,

Any ideas on this? We still have doubling, but for the correct sub classes. Any advice is much appreciated.

Thanks.
Photo of Paul

Paul

  • 442 Points 250 badge 2x thumb
Hi,
I'm having the same issue, but I think the difference may be the fact that I'm using a date field or formula field...

I've created a formula field that determines the close year (off opportunity close date) so I can pass in the aggregate year value into the condition for the drawer model.  This works fine with no context and with one drawer, but when I open a second, it of course then updates to show the new (and old) rows in both drawers.  I can't get any context setting to return any rows. 

Any thoughts on what the context should be?  I try putting the grouping alias (cyCloseDate) like this:

 <condition type="contextrow" field="cyCloseDate" mergefield="CloseDate" operator="="/>

as well as many other combinations, but the drawers are always empty.

Thanks!
Paul