No "name" field available in aggregate model

  • 2
  • Question
  • Updated 4 years ago
  • Answered
I have an aggregate model based on a client encounter object... i can link to fields in the related client object (there is a Client__c field in client encounter)... but when i try to add the "name" field from the client object..............i don't see it in the list........... the "id" field is there, but not the "name" field. Is this something about aggregate models ?
Photo of ktyler

ktyler

  • 9,244 Points 5k badge 2x thumb

Posted 5 years ago

  • 2
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Hi Ken, you are correct about Name fields sometimes not showing up in the list of fields to pick from in Aggregate Models --- this happens whenever you Name field is an "Auto-Number" field. Apparently Salesforce refuses to let you group aggregate queries by auto-numbers --- not sure why, but it's a Salesforce limitation, not a Skuid limitation.

However, there is a workaround to be able to get at the Name field value:

1. Create a plain text field to store the true Name field (e.g. your "Client Id"). Call the field something like "Client Id (Read Only)". It's not "truly" read-only, but you should not add this field to any Skuid or Salesforce page layouts, it's just supposed to be there in the database so you can use it for special scenarios like this.



2. Create a Workflow Rule (or Trigger) which, whenever a new Client record is created, or its Name field is updated (which is impossible for auto-number fields, so never mind...), does a Field Update to dump the value of the Name field into the "Client Id (Read Only)" field.

(The Workflow Rule)



(The Field Update)



3. To make sure all of your existing records have this field populated, use Data Loader, Anonymous Apex, or some other tool to go through and copy the value of each Client record's Name field into the Client Id (Read Only) field. From here on out, your Workflow Rule will take care of ensuring that this field is populated.

4. Now, from your Aggregate Model "Groupings" area, navigate into the "Client" field's related fields, and voila, there's your Client Id (Read Only)! You can now use this as an Aggregate grouping field.



5. Here's what a sample Aggregate table using this data would look like. To include the ClientId field in your table

(Skuid Page)



(Result)

Photo of Nicholas Playoust

Nicholas Playoust

  • 258 Points 250 badge 2x thumb
Zach - thanks for the explanation about the auto-number limitation.  The aggregation works but the name won't show up, so I used something similar to your suggestion.