⚡lightning component mini series⚡- field sets

With lightning, you can now create components that you can show/hide not just depending on the record type (like you're already used to in classic). But also depending on values held on the record itself too.

In this example we have an external process running in an SQL database which identifies if there are multiple accounts that are in fact the same 'person'; and we are fed information in salesforce that lets us build a grouping of accounts to represent this structure.

Now from a sales perspective it would be really useful to see the key metrics per account rolled up to the master/parent account so sales can see the true metrics at a glance behind the grouping.

So first I created a parenting process that would build the account structures correctly according to each record having a global id and a global id of a parent (if it had one) and to keep that parent structure in-sync as changes were applied.

I used flow to do this which turned out to be quite resource intensive but ok if you are not making thousands of changes per 24hr period to your parented structures.

In this parenting process I also perform roll ups within one of the flow assignment modules. I take the fields per account I am interested in returning a total for and then write these totals to a new set of fields I created on the account.

the entire process (isnull decisions for error handling)
its now this easy to have roll up functionality!

Great we now have our account structure AND summarized values; BUT now you'll find the only way to display the data is to either switch the record type out for the parent (a bit old school) OR create a lightning component (which annoyingly at the time of writing has to be made from scratch with its own controller blah blah blah).


First install the package below... (enter in your prod/sandbox details to install in your preferred location).

Deploy to Salesforce

Now make an account field set (you may have to go back into classic to get this feature to show in the setup menu). It should look something like this.

Now go back into lighting click on the setup cog and 'edit page' for the account. Drag in the new custom component called "Field Set Output Selection" and enter the api name of the field set you just created. Set any other optional values for this component including the display criteria so that you only display it on parent accounts! - don't for get that, its kinda the most important part!

And you're done! 🎩✨🐰