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