Before Summer 18, to read parameter in Lightning Component, we had to wrap Lightning Component in Lightning Application. After Summer 18, it has changed for good.
In this blog post we would create a formula field to launch Lightning Component (yes, you read it right). And then we would read URL parameter in Lightning Component using pageReference provided by interface lightning:isUrlAddressable.
Create a formula field on Account to launch Lightning Component and read its parameter.
Most of us are big fan of Flow but at the same time we miss a lot of obvious features like lookup fields, model dialogues etc. This blog post might bring excitement and motivation to give more attention and love to Flow.
Most obvious idea to improve Lightning Component Performance is to avoid server trips. Let’s say, you need to know the queue Id to be assigned as owner in Case and also need custom setting information to derive the behavior of Lightning Component. There are two ways to achieve this – Call Apex Controller two times vs return combined results from Apex in single call and process JSON in client side controller of Lightning Component.
2. Use Storable Action
In this approach, Lightning component shows cached result instead of making immediate server trip. Lightning component will make server (Apex) call in background and if cached result is stale, then it would cache and refresh the lightning component. This is very useful for devices which has slow internet connections. If you are Facebook or Google News user, you would be easily relate it. When we open these apps, it shows previous feed and if there are new feeds, it gives us option to refresh view or automatically refresh it. All you have to do is, on client side controller of Lightning component, mark action as storable using this code action.setStorable(). This blog post explains working of storable action in detail.
Note : Everything we are discussing here is completely covered as part of Live coding in Apex Salesforce Saturday organized by Amit. Would like to thank Mohith for his support and answers during the demo. It also shows How SalesforceDX can be used daily by developers to perform development.
Salesforce Path is awesome feature, where you can display picklist value at top of record page and on click, it updates value in Salesforce database. However same solution does not fit in all scenario. Consider situation where picklist field is supposed to be changed by some other process or Integration. Now you don’t want anyone to change it from user interface. Even though you like Salesforce Path to show summary at top of page however it won’t be useful in above scenario.
Because of this, I created a Read Only Path Component in Lightning. I tried to keep same look and feel as of Standard Path component. This component will need only two inputs
Record Id – It would be automatically passed if we use it using App Builder
Field API Name – API name of picklist type of field
Now think about it. Only thing I got is Record Id. How would I know Object Name ? How would I know all picklist values for field name supplied ?
If you have worked on Visualforce and started playing with Lightning Component, you must have identified one important missing feature, which is standard Controller.
Lets assume a scenario, you have two Lightning Components on Account page. One Lightning Component is used to show some fields and other component is used to edit same record.
Problem 1 :
To achieve this, both Lightning components would invoke Apex method separately at the cost of performance, by issuing duplicate server calls. Below image depicts problem, where multiple Lightning component requests same content by making separate server calls.
Before, jumping directly to source code, lets first discuss some important points.
I have posted few articles on Lightning Out. In this post, we will see how Lightning components can be displayed on public website. To access these Lightning components, users don’t need to login to Salesforce.