Dynamically Show/Hide Lightning Components

Share this article...

A nifty feature of the recent Winter ’18 release, is the ability for all Lightning Experience users to make their components dynamic. This feature was proudly showcased at the Admin Keynote this year at Dreamforce. This simple but effective feature now means you can show or hide the components you add to your pages, based off of your records field values.

In standard Salesforce fashion, we have been given an easy to use click and point interview now available on most standard and all custom components. From the screenshot on the right you can see the kind of filters that can be added using the “Set Component Visibility” section. You can also determine how you want the filters to work together; If all are true, if any are true, or create your own custom logic e.g. “(1 OR 2) AND 3”.

With this functionality being so easy to use and readily available on all of your favourite Lightning components, I can bet this is setting off all the synapsis in your brain on all the use cases you can implement in your organisation. But if you haven’t had your coffee yet, here are a few to get you started. Also if you are interested in the standard Lightning components you can add right out of the box, check out this post.

Single Related List – Approvals

With the “Related List – Single” component, you can add a single related list (Not every one on your page layout) anywhere on your page. This means that you can now show or hide related lists that are only relevant when a record is at a certain stage or a field has a certain value. For example you can show an approval history of a record, but only when the record has been entered into an approval process. This can potentially make your page layouts a lot cleaner, by not showing empty related lists.

Rich Text – Alerts

The Rich Text component is a simple yet effective widget that allows you to add Rich Text and simple HTML to your lightning pages. One example of using this with the dynamic feature, is to show certain bits of key information when relevant on a record. This could be used effectively with alerts when an account is potentially at risk of churning, or a certain activity has not been carried out on a lead/opportunity. You could also add CPQ type alerts when a customer qualifies for a discount or promotion on an Opportunity.

Flow – Customer Survey

With the fantastic addition of Flow components in Lightning that came about in Winter ’17, this allows us to embed great looking visual flows on our page. I recently created a customer survey flow for a client looking to ask their customers questions about their service. sWith the new dynamic feature we can now only make sure this flow appears when the account is actually a customer, and when they are actually due a survey.

Formula Fields = Endless Possibilities

After a long period of playing around with dynamic components, the type of use cases that can be implemented, and the fields that can be used to kick off the showing or hiding of these components, I’ve uncovered you can use formula fields! At first I was doubtful, as we all know these elusive fields sometimes don’t work with other Salesforce features, but I was pleasantly surprised. The fact that formula fields can be used means that we can create complex calculations such as the health of an account based off of various factors, and have components show almost like magic. Whilst testing through some scenarios, I’m also glad to let you know that as soon as values are changed and the record is saved, components will show or appear. Great news!

What are your current use cases? Or what are you considering about implementing for your company? Let me know in the comments!

3 thoughts on “Dynamically Show/Hide Lightning Components

  1. These sound great IF you are using Lightning. And it’s in line with SF’s push to get everyone off Classic. But for those users (I wonder what % are still on Classic and do not have plans to migrate), it does nothing. And there are many many cases where Lightning is not appropriate. SF is basically ignoring them, or seemingly placating them by giving them fairly insignificant additions while not addressing the many real needs that they have.

  2. Pingback: Dynamically Show/Hide Lightning Components

  3. Iegor Nechyporenko


    Seems like there is a problem with this feature, as it’s impossible to deploy those filters through the ant or changesets. So it should be manual step on all the environments

Add Comment