Skip to main content

Let’s play - Is It Possible!!


Is it possible to summarize a child relationship of a parent object?


Use case using native objects:

Accounts, Contacts, and Cases


When I am looking at a table of Cases, can I display a list of the Contacts from that account in the table?


I attached a low tech example.


Note: I know that the option to do this isn’t available through the Page Builder (fields –> child relationships), so I would expect it would be something that I’d do through the XML


Thanks!

You can use DLRS to Concatenate the Names from the Contact records into the Account record. You alternatively Concatenate the Contacts Ids and create a custom field renderer and model to make them clickable.


I was hoping to find a lighter weight alternative to DLRS, but it’s currently how I circumvent the problem. Am I SOL otherwise?

The custom field renderer idea is a killer idea!


Is there a way to make something like this work:



  1. XML built by the Page Builder:




  2. Tweak it to something like this:




Ahhh, I’d just go through the good ol’ references in Salesforce (adding a custom relationship from Account to Contact - 1:m). That, or write the table down with JS 🙂

No idea how to do it on the XML straight tho.


Unfortunately not. Skuid models are limited to SOQL capabilities and this ins’t possible. Think you’re stuck with building a custom field rendered for this requirement.


Unless, the relationship between Account and Contact exists.


It does, but I’m not certain that a Accounts’ Contacts can be retrieved when the SOQL is “Select Id, Account FROM Case”.

Where in this SOQL can Contacts related to the Account be pulled in?


As simple as querying the reference name and the field you want:

Let’s say there’s a lookup relationship between Account and Contact called Contact__c, so:

rSELECT Id, Contact__r.Name FROM Account WHERE ID = ‘something’ ];

The Contact__r lets you access Contact directly to the record it is related to. 


er … uh … the model is based on Case. So the SOQL is “FROM Case”.


Ok. Here is the way. 100% declarative. No XML, No Formula Fields, No Javascrpt, No APEX…


Just use multiple models, and UI only relationships between them.


(honestly guys, this came to me as I was lying awake last night… that’s just how my life is…)


Details… Create two models.


  1. Account model

  • This one has to be first in model order

  • Add contacts child relationships

  1. Cases model.

  • Make sure the AccoundId is included in this model

  • Create a UI Only field on this model that uses the “ModelLookup” function. Lookup the child relationship on the Accounts model. The syntax in my case looked like this:

MODEL_LOOKUP(‘Accounts’,‘Contacts’,‘Id’,{{AccountId}})



  1. Build a table on the Cases model with your case subject, account name and whatever else you want.




  2. Add a template to the table where you retrieve data from the contacts object record retrieved from the Account model. You can’t just drag the UI Only field into your table because it just has an object in it (You get “object:object” in your fields. But you can use a template to dig down into the object and show its data. The template syntax I used was:



{{#AccountContacts.records}}{{Name}}

{{/AccountContacts.records}}


CAVEAT: I’m not sure this solution scales well. It requires you to have all the accounts that are going to be in model 2 pre-loaded in model 1. If you have hundreds of accounts - that might be fine. But if you have thousands of accounts it will be problematic. You might be able to use the cross model filter synching tools that Pat Vachon introduced last year, or something else… But that’s just word to the wise.


Here is a picture:



(note - you can see the two cases for salesforce.com… Proving that this model is built on the cases object. )


Here is the xml for my page:


<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true"> <models> <model id="Accounts" limit="20" query="true" createrowifnonefound="false" adapter="salesforce" type="" sobject="Account"> <fields> <field id="Name"></field> <field id="Id"></field> <field id="Contacts" type="childRelationship" limit="10"> <fields> <field id="Name"></field> </fields> </field> </fields> <conditions></conditions> <actions></actions> </model> <model id="Cases" limit="20" query="true" createrowifnonefound="false" adapter="salesforce" type="" sobject="Case" doclone=""> <fields> <field id="Subject"></field> <field id="AccountId"></field> <field id="Account.Name"></field> <field id="AccountContacts" uionly="true" displaytype="FORMULA" readonly returntype="TEXT"> <formula>MODEL_LOOKUP('Accounts','Contacts','Id',{{AccountId}})</formula> </field> </fields> <conditions></conditions> <actions></actions> </model> </models> <components> <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Cases" buttonposition="" mode="read" uniqueid="sk-nXhXn-357"> <fields> <field id="Subject" valuehalign="" type=""></field> <field id="AccountId" valuehalign="" type=""></field> <field type="COMBO" valuehalign=""> <label>Account Contacts</label> <template>{{#AccountContacts.records}}{{Name}}

{{/AccountContacts.records}}


This is super cool. Haven’t seen this formula yet. Model_Lookup is a hidden gem.

Kinda like Model cloning. Hidden and under utilized.


Totally under utilized.

This is brilliant!