Monday, October 30, 2017

Lightning Tree : Generic Lightning Component to Display Hierarchy for any sObject

In API version 41.0, Salesforce has introduce new component called lightning:tree. This can be used to display hierarchy in tree structure. Before this, we have to used jquery or other javascript libraries to implement this.

After introduction of lightning:tree, it is very easy to use this and implement this in short time.

I have created a generic lightning component to display records hierarchy in tree structure. You just have specify below attributes to component to display tree structure:

  • ltngcurrentRecId : Salesforce 15 or 18 digit Id of any record for which you want to see hierarchy.
  • ltngSobjectname : sObject API name (like Account, Case, Position__c etc.)
  • ltngParentFieldAPIName : Field API name which creates self relationship between records.
  • ltngLabelFieldAPIName : Field API name which will be used to display records in tree structure(like Name, CaseNumber, Title__c etc.).
  • ltngHierarchyHeader : Header label which will be displayed above tree structure.


Below is complete complete code for your reference:


You can use this code as reference and can implement different logic.

Hope this will help!!!

Looking forward for everyone's comments and suggestions.

43 comments:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or learn thru Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry. JavaScript Training in Chennai

    ReplyDelete
  2. Is there any way to return additional fields for the tree as well? Perhaps even just a name + text field?

    ReplyDelete
  3. Hi,

    Create formula field and concatenate all the fields values as per required format and then refer that formula field in "ltngLabelFieldAPIName" attribute.
    ltngLabelFieldAPIName="UniqueValue__c"


    Hope this helps!!

    Thanks

    ReplyDelete
  4. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
    Advanced AWS Training in Bangalore | Best Amazon Web Services Training Institute in Bangalore
    Advanced AWS Training Institute in Pune | Best Amazon Web Services Training Institute in Pune
    Advanced AWS Online Training Institute in india | Best Online AWS Certification Course in india
    AWS training in bangalore | Best aws training in bangalore

    ReplyDelete
  5. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
    microsoft azure training in bangalore
    rpa training in velachery| rpa training in tambaram |rpa training in sholinganallur | rpa training in annanagar| rpa training in kalyannagar

    ReplyDelete
  6. Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
    Best Devops online Training
    Online DevOps Certification Course - Gangboard

    ReplyDelete
  7. Want to have fun and get paid for it? we have bonus slot machines .Come to us and have fun getting money for it.

    ReplyDelete
  8. Thanks Admin for sharing such a useful post, I hope it’s useful to many individuals for developing their skill to get good career.
    python Course in Pune
    python Course institute in Chennai
    python Training institute in Bangalore

    ReplyDelete
  9. Thanks For Sharing The Information The Information shared Is Very Valuable Please Keep Updating Us Time Just Went On reading The Article Aws Online Course Python Online Course Data Online Course Hadoop Online Course

    ReplyDelete
  10. Hi, is it possible to create a similar dynamic lightning:treeGrid or modify the above code to use lightning:tree within aura:iteration to meet the requirement? Thanks!

    ReplyDelete
  11. Attend The Python training in bangalore From ExcelR. Practical Python training in bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Python training in bangalore.
    python training in bangalore

    ReplyDelete
  12. Attend The Best Python Training in Bangalore From ExcelR. Practical Python Training in Bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Best Python Training in Bangalore.

    ReplyDelete
  13. I am looking for and I love to post a comment Python training in punethat "The content of your post is awesome" Great work!

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. ExcelR offers data science training in hyderabad , the most comprehensive Data Science course in the market, covering the complete Data Science lifecycle concepts from Data Collection, Data Extraction, Data Cleansing, Data Exploration, Data Transformation, Feature Engineering, Data Integration, Data Mining, building Prediction models.

    ReplyDelete
  16. Awesome Blog, It helped me to get into the next level and had lot of information in it, I really appreciate. Thanks for sharing this information. Keep blogging!! machine learning course bangalore

    ReplyDelete
  17. Attend The Course in Data Analytics From ExcelR. Practical Course in Data Analytics Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Course in Data Analytics.
    ExcelR Course in Data Analytics

    ReplyDelete
  18. Attend The Data Analytics Courses in Bangalore From ExcelR. Practical Data Analytics Courses in Bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Analytics Courses in Bangalore.
    ExcelR Data Analytics Courses in Bangalore

    ReplyDelete
  19. My spouse and I love your blog and find almost all of your post’s to be just what I’m looking for. Artificial Intelligence Course

    ReplyDelete
  20. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
    data analytics courses

    ReplyDelete
  21. Very interesting blog Thank you for sharing such a nice and interesting blog and really very helpful article.sap mm Training in Bangalore

    ReplyDelete
  22. Its really helpful for the users of this site. I am also searching about these type of sites now a days. So your site really helps me for searching the new and great stuff.sap basis Training in Bangalore

    ReplyDelete
  23. Very useful and information content has been shared out here, Thanks for sharing it.sap hr Training in Bangalore

    ReplyDelete
  24. I gathered a lot of information through this article.Every example is easy to undestandable and explaining the logic easily.sap sd Training in Bangalore

    ReplyDelete
  25. These provided information was really so nice,thanks for giving that post and the more skills to develop after refer that post.sap bw Training in Bangalore

    ReplyDelete
  26. Your articles really impressed for me,because of all information so nice.sap ehs Training in Bangalore

    ReplyDelete
  27. Linking is very useful thing.you have really helped lots of people who visit blog and provide them use full information.sap ehs Training in Bangalore

    ReplyDelete
  28. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving.sap bods Training in Bangalore

    ReplyDelete
  29. Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.sap abap Training in Bangalore

    ReplyDelete
  30. I know that it takes a lot of effort and hard work to write such an informative content like this.sap fico Training in Bangalore

    ReplyDelete
  31. Nice information, valuable and excellent work, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here. data science course

    ReplyDelete
  32. Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!
    Please check ExcelR Data Science Certification

    ReplyDelete
  33. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it.
    ExcelR Data Analytics Course

    ReplyDelete
  34. This post is very simple to read and appreciate without leaving any details out. Great work!
    Please check ExcelR Data Science Courses

    ReplyDelete