Skip to main content

Posts

Showing posts from June, 2016

Tree Structure for Self related records in salesforce

How to build a tree for the records which has self lookup? Here I am taking a custom object called Category__c and created a self-lookup to it with the field FKParentCategory__c. Controller: public without sharing class categoryTreeController {       List<Category__c> parentrecord;     Map<Id, List<Category__c>> categoryMap{get;set;}     public string treeJSON{get;set;}     public string treeJSON2{get;set;}     private string whereClause;     public integer count{get;set;}     public categoryTreeController ()     {         treeJSON='[';         count=0;         whereClause='';               string pageName=ApexPages.currentPage().getParameters().get('pageName');         if(pageName=='clientPage'){             whereCl...