Skip to main content

Recent Items - Custom Lightning component

Here comes the another #Salesforce custom lightning component blog post. With this custom lightning components its easy to get the recent items of an object with dynamic fields and also it allows to limit the number of recent records you want to display in the page. This simple lightning component UI is designed with the salesforce lightning design system



Let's get into the details, The recently viewed records of the current user are stored in the RecentlyViwed object which includes the user information, ID and object name of the recently viewed record. The following apex code contains the logic to get the recently accessed records. The logic is straightforward we will pass the following user input values name of the object, fields to get and the number of the records to be returned. The annotation @AuraEnabled allows the lighting javascript controller to call the method



The above apex class will be called from the lightning javascript controller doInit function. Below is the lightning controller code



The syntax to call the apex controller from lightning javascript is component.get(“c.MethodName”) you can able to pass parameters to the method using action.setParams({parameters}); here we will be sending the ObjectName, Field names and limit as parameters. The setCallback function where we will form the table dynamically for the returned values from the apex controller.



Final & the important part of the component is UI which should give the native look and feel, so I chose Lightning Design system which brings the new salesforce lightning UI design for the custom component. The lightning component is easy to use similar to the other UI design system. To know more about the lighting design system check this link - https://www.lightningdesignsystem.com/



The complete source code of this component is in the following Github repo - https://github.com/Karanraj/RecentItems-Lightning



Comments

  1. I am so happy to found your blog post because it's really very informative. Please keep writing this kind of blogs and I regularly visit this blog. Have a look at my services.
    Cyber Security Training Course in Chennai | Certification | Cyber Security Online Training Course | Ethical Hacking Training Course in Chennai | Certification | Ethical Hacking Online Training Course | CCNA Training Course in Chennai | Certification | CCNA Online Training Course | RPA Robotic Process Automation Training Course in Chennai | Certification | RPA Training Course Chennai | SEO Training in Chennai | Certification | SEO Online Training Course

    ReplyDelete
  2. Nice information, this is will helpfull a lot, Thank for sharing, Keep do posting i like to follow this ui online training
    ui design course
    ui training
    online ui training

    ReplyDelete

Post a Comment

Popular posts from this blog

Avoid Duplicate Records Using Flow

In this blog post lets see how to avoid duplicate records in Salesforce using the powerful feature – Flow , As the word says, flow easily flows to fulfill the requirements with ease. ☺  Many think of appexchange solutions and source code to avoid the duplicate record in salesforce, But the method I'm going to explain here is completely different and very simple. It helps you to reduce your code and can easily rebuild for other objects with different field logic with simple clicks. Lets jump into the solution, we will use flow to check duplicate record logic and use apex trigger to initiate the Flow whenever a record is created or updated. Visual Work Flow : [Click] First we will create the Flow to check the duplicate records based on the name and store the result in the variable. In this example, we will use the Account object for the dupe check. Step 1  : Create a new visual flow with the Name ‘ DuplicateAccountCheck ' Step 2  : Click and drag the RecordLookup into t

Plan your Dreamforce with “Dreamforce Trail”

Salesforce has many good resources for anybody looking to begin Salesforce as beginner, Intermediate or Advanced. Trailhead is also one among the good resource to learn salesforce and my favorite too. I have also written blog post about Trailhead & my favorite module   This  blog post covers an interesting and helpful Trailhead module. Yes Its all about ' Dreamforce Trail ', if you are a Dreamforce Attendee, then I strongly recommend you to take a look into this Trailhead module. No Admin skill or No Developer skill is required for this module.Start winning Badges and is gamified so it motivates you to reach more badges and finally you end up gaining knowledge on Salesforce. Why do we have Dreamforce Trail module in Trailhead?  To help people who is coming to dreamforce for the first time and to plan well for the events. Dreamforce is a tech feast for anybody. Dreamforce is salesforce festival. If you don’t plan well, you will miss something highly helpful . This Dre

Export records from List view – ListView API

As part of the Winter’15 release salesforce introduced the List View API features which helps us to get details and records of list views for an object. I was started exploring more about the List view API and trying to build an use case using that. So I searched about List View in the IdeaExchange site then found that many users are looking for a solution to export records to excel directly from the list view. I built a solution for that Idea, which helps user to download all the records directly from the List view for both standard and custom object. You don’t have to make any change in the code to use this functionality for different objects. All you need is to create a custom button for that object as mentioned below. Lets take an example for Account object 1. Go to Setup –> Accounts –> Buttons, Links and Actions 2. Click ‘New Button or Link' 3. Enter  Label, Name and select display type as ‘List Button’ 4. Content source as “Onclick Javascript” and paste the