• Deepika Gupta 26
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 28
    Questions
  • 20
    Replies
Hi All,
Hi All,
Have a Req that in one process builder on Contact new task is created with following conditions :
1) Priority Picklist Normal
2) Status Picklist Completed
4) NameId Refrence [Contact].Id.
But on the creation of the new task the Business unit is picked by Contact Owner Business unit but i want it should be of task's owner Business unit.could any suggest how i can achieve it.
Could any one suggest is it possible?
 
Hi All,
​I want that in my if statement like if(Field1==true) //this is a checkbox field

     Restrict user to fill the Field2 & Field3 //this two fields are picklist field
}

All this three fields are on same object that is "Acccount:" let me know how is it possible to achieve in apex code.
Hi All,
I want that in my if statement like if(Field1==true) //this is a checkbox field

     Restrict user to fill the Field2 & Field3 //this two fields are picklist field
}

All this three fields are on same object that is "Acccount:" let me know how is it possible to achieve in apex code.
Could any suggest that why i am getting this error :

Expression cannot be assigned at line -1 column -1

After saving this method 

 public static void TempAcc()
    {
       if( Account.RecordTypeId ='ParticularId')
        { 
          
               // system.debug('Account category needs to be blank when parent account is selected');
          
       }
     }




 
have a req that when i create new account that is RecordType ="Temporary Account" && Parent Account <> blank or Top Level account <> then make two field read only that is account category and account subcategory.Is it possible via validation rule?if yes,then how please suggest.
I have Req that when the new record is created that is temp account and if the parent account field is not blank then account category and subcategory must be blank.is this possible via validation rule?i yes then could any one suggest that how to do that
Hi All,
This is my code of VF page where i have already set sidebar and showheader still its not showing both the things and only showing data on blank page which is not looking fine.please suggest how can i solve this issue
<apex:page standardController="Account" sidebar="true" tabStyle="Account" showHeader="true" extensions="WithContactButtonController">

<apex:form >

<c:HierarchyTree currId="{!Account.id}" />

<input type="button" value="Back to Account" onclick="window.history.back()" /> <b><apex:commandLink action="{!doSomething1}" target="_top" value="IncludeContact" id="theButton"/></b>

 
Hi All,
I have a requirement that i am navigating from a link on VF page to another VF page now i want to create a link to go that partcular account from where i drilldown means on that particular account.Could any one suggest please how to do that?
Hi All,
Below is my code of VF page that i am rendering from another page via link :
Visualforce Page: Hierarchy_Clone 

<apex:page standardController="Account" showHeader="true" sideBar="true">
<apex:form > <c:HierarchyTree currId="{!Account.id}" />
</apex:form>
</apex:page>

But i am not getting a desire page because its not opning with sidebar and header.please suggest how to solve this issue.
I have a urgent requirement i know its very small thing but i am not able to achieve it.I am on account detail page in this page in this page there is one VF Page means in middle like means division like Account deytails,address information and account hierarchy section now in this account hierarchy section i have a page hierarchy page in this page i have created a link that has to navigate in front of account detail page not on the diffrent tab. i have used 
VF page :
Visualforce Page: HierarchyPage ~ Salesforce - Unlimited Edition<apex:commandLink action="{!doSomething}" target="_self" value="Show_Hierarchy" id="theButton"/>

Controller 

Salesforce - Unlimited Editionpublic with sharing class WithContactButtonController
{
    private ApexPages.StandardController standardController;

    public WithContactButtonController(ApexPages.StandardController standardController)
    {
        this.standardController = standardController;
         System.debug('HelloDeepika');
    }
     public PageReference doSomething()
    {
        // Apex code for handling record from a Detail page goes here
        //Id recordId = standardController.getId();
        PageReference pageRef = new PageReference('/apex/Hierarchy_Clone');

         System.debug('HelloDeepika1');
        return pageRef ;
       
    }

   }

Now the new page that is Hierarchy_clone is opning on that particular section itself of accounthierarachy but i want it to open in the full account detail page not sure how to achieve this.
How can i go to the particular accounid from where i have navigated from the VF Page.Means i have clicked on a particular account and navigated to the another view means VF page now from that page i want a link that will navigate me again on that particular id from where i have navigated.
how to create a link on vf page that will navigate to another vf page but in same window means on parent window
How can i create a link on one VF page that will navigate to another VF Page.I am able to that but its opening in new tab i want it on parent window just like popup.could anyone suggest how to solve this?
Could any one suggest how to get understanding of the JTreeNode methods like Salesforce - Unlimited Editionpublic JSTreeNodeState(Boolean opened, Boolean disabled, Boolean selected) {
      this.opened = opened;
      this.disabled = disabled;
      this.selected = selected;
    }
It is used in existing code and i want to know that what the acutual meaning of this Parameters.
Hi All,
Need help on an urgent issue.Requirement is to create a hierarchy of Parent Account its child and its corresponding contact.
Controller Class--->

public without sharing class HierarchyTree {

    public static String currentId {get; set;}

    private static Account currentAccount {
        get {
            if (currentAccount == null) {
                currentAccount = [select Name, ParentId, UltimateParent__c From Account where Id = :currentId];
            }
            return currentAccount;
        }
        private set;
    }

    private static Account ultimateParentAccount {
        get {
            if (ultimateParentAccount == null) {
                if (currentAccount.UltimateParent__c != null) {
                    ultimateParentAccount = [select Name, ParentId, UltimateParent__c from Account where Id = :currentAccount.UltimateParent__c];
                } else {
                    ultimateParentAccount = currentAccount;
                }
                currentAccount = [select Name, ParentId, UltimateParent__c From Account where Id = :currentId];
            }
            return currentAccount;
        }
        private set;
    }
    
    /**
     * @description This methos is used to generate JSON data for jsTree component
     */
    public static String getJsonTree() {
        List<JSTreeNode> listItems = new List<JSTreeNode>();
        listItems.add(
            new JSTreeNode(
                ultimateParentAccount.Id,
                '#',
                ultimateParentAccount.Name,
                new JSTreeNodeState(true, false, false),
                new JSTreeNodeAAttr(String.valueOf(ultimateParentAccount.Id) == currentId ? 'font-weight:bold' : '')
                
            )
        );
        for (Account acc : AccountHierarchyServices.getAllChildren(new List<Account>{ultimateParentAccount})) {
            listItems.add(
                new JSTreeNode(
                    acc.Id,
                    acc.ParentId,
                    acc.Name,
                    new JSTreeNodeState(true, false, false),
                    new JSTreeNodeAAttr(String.valueOf(acc.Id) == currentId ? 'font-weight:bold' : '')
                )
            );
        }
        return JSON.serialize(listItems);
    }

    /**
     * This class is used to generate jsTree node
     */
    @TestVisible private class JSTreeNode {
        public String id; //required
        public String parent; //required
        public String text; // node text
        public String icon; // string for custom icon
        public JSTreeNodeState state; // instance of JSTreeNodeState
        public Object li_attr; // attributes for the generated LI node
        public JSTreeNodeAAttr a_attr; // attributes for the generated A node
        
        public JSTreeNode(String id, String parent, String text, JSTreeNodeState state, JSTreeNodeAAttr a_attr) {
            this.id = id;
            this.parent = parent;
            this.text = text;
            this.state = state;
            this.a_attr = a_attr;
        }
    }

    @TestVisible private class JSTreeNodeState {
        public Boolean opened; // is the node open
        public Boolean disabled; // is the node disabled
        public Boolean selected; // is the node selected

        public JSTreeNodeState(Boolean opened, Boolean disabled, Boolean selected) {
            this.opened = opened;
            this.disabled = disabled;
            this.selected = selected;
        }
    }

    @TestVisible private class JSTreeNodeAAttr {
        public String style; // style of current node

        public JSTreeNodeAAttr(String style) {
            this.style = style;
        }
    }
    
}
 
Visualforce Component --->

<apex:component controller="HierarchyTree">
	
	<apex:attribute name="currId" description="This is the Account Id for displaying Acccount Hierarchy" type="String" required="true" assignTo="{!currentId}"/>

	<apex:outputPanel rendered="{! currId == null}" layout="none">
		<span style="font-size:16px; font-weight:bold; padding-top: 15px; display: inline-block;">{!$Label.AccountIdIsRequired}</span>
	</apex:outputPanel>

	<apex:outputPanel rendered="{! currId != null}" layout="none">

		<apex:stylesheet value="{!URLFOR($Resource.jsTree, 'dist/themes/default/style.min.css')}"/>
		<apex:includeScript value="{!URLFOR($Resource.jquery_1_11_3)}"/>
		<apex:includeScript value="{!URLFOR($Resource.jsTree, 'dist/jstree.min.js')}"/>

		<script>
			var j$ = jQuery.noConflict();

			j$(function(){

				j$('#jstree')
				// listen for event
				.on('changed.jstree', function (e, data) {
			        if( (typeof sforce != 'undefined') && sforce && (!!sforce.one) ) {
			            // Salesforce1 navigation
			            sforce.one.navigateToSObject('' + data.selected);
			        } else {
			        	// Set the window's parent URL using a javascript expression
			            window.top.location.href = '/' + data.selected;
			        }
				})
				// create the instance
				.jstree({
					'core' : {
						'data' : {!JsonTree}
					}
				});

			});
			
		</script>

		<div id="jstree"></div>

	</apex:outputPanel>

</apex:component>
 
Visualforce Page--->


<apex:page standardController="Account" > <apex:form >

<c:HierarchyTree currId="{!Account.id}" />


  <apex:outputLink value="https://bd2--cgkt.cs87.my.salesforce.com/001/o"><h1><b>Back to Account List</b></h1>!</apex:outputLink> 
<a href="?#"><font style="color:blue;">Exclude Contact</font></a> | <a href="?#"><font style="color:blue;">Include Contact</font></a>

</apex:form>

</apex:page>

Its Working fine and showing me the hierarchy of Account : 

Now my concern is i am not able to associate contact in the HierarchyTree first my thought was that i can make sub query or may be its call nested query like this in Hierarchy Tree Methods :

private static Account currentAccount {
        get {
            if (currentAccount == null) {
                currentAccount = [select Name, ParentId, UltimateParent__c,(select id,name from contacts) From Account where Id = :currentId];
            }
            return currentAccount;
        }
        private set;
    }

But its not returning me any row.then one suggestion i got is that i should use map for account and contact like 

 public Map<Id,Contact> contactsMap {
        get {
            if (contactsMap == null) {
                contactsMap = new Map<Id,Contact>();
                for (Account acc : [select Id, (select Id, FirstName, LastName from Contacts) from Account where Id = :currentId]) {
                    for (Contact c : acc.Contacts) {
                        contactsMap.put(c.Id, c);
                    }
                }
            }
            return contactsMap;
        }
        private set;
    }

But i am not sure how acutully i need to use map to get associate contact because that variable current account is also used in the another method to get parent account.Could someone suggeste me a proper way to associate contact in my current code.and how can i render this map to get hierarchy form in VF page means which method should i use to get contact and how i can use this method in <repeat> to get child in tree form.Please suggest its on Priority and not getting proper solution to show it in required format for contact. 
 
Hi,
I have synced my salesforce outlook with my developer org but now i have to change the enviorment.and have to connect with a new sandbox.so is it possible to change the connected enviorment or i have to reconfigure for other enviorment.
Hi All,
I have a requirement that on the click of account save button it has to check whether loginName and Keymanagername(Field on account which has lookup with user) are same or not if yes then assign it to one permission set.
As per my understanding i have Wriiten this in Account Handler Class 
Id userId=UserInfo.getUserId();
String userName=[Select Id, Name From User Where Id =:userId].Name;
system.debug('username'+userName);
and Created a list object on handler class like private List<KeyAccountManager__c> keymanagersFromAccounts = new List<KeyAccountManager__c>();
But i am not sure how can i compare this both because one is string and another is list object.Could any one that what would be the right approach for it.should i need to find all accounts keymanagers in a field and have to put a loop to check its matching with usename or not.I dont have a clear understaning that how to achieve this.
Could any one suggest that how can i get current user name and comare it with one the field of the account which has a lookup with user after trgger insert/update.
Could any one suggest that getJsonTree() method calls from where because i have code in which account hierarchy is aleardy diplaying but now i have to associate contact to it.
@description This is the controller class for HierarchyTree component

public without sharing class HierarchyTree {

    public static String currentId {get; set;}

    private static Account currentAccount {
        get {
            if (currentAccount == null) {
                currentAccount = [select Name, ParentId, UltimateParent__c From Account where Id = :currentId];
            }
            return currentAccount;
        }
        private set;
    }
    
    private static Contact currentContact {
        get {
            if (currentContact == null) {
                currentContact = [select Id From Contact where AccountId = :currentId];
            }
            return currentContact;
        }
        private set;
    }

    private static Account ultimateParentAccount {
        get {
            if (ultimateParentAccount == null) {
                if (currentAccount.UltimateParent__c != null) {
                    ultimateParentAccount = [select Name, ParentId, UltimateParent__c from Account where Id = :currentAccount.UltimateParent__c];
                } else {
                    ultimateParentAccount = currentAccount;
                }
               
            }
            return ultimateParentAccount;
        }
        private set;
    }
    
    
    
    
    /**
     * @description This methos is used to generate JSON data for jsTree component
     */
    public static String getJsonTree() {
        List<JSTreeNode> listItems = new List<JSTreeNode>();
        listItems.add(
            new JSTreeNode(
                ultimateParentAccount.Id,
                '#',
                ultimateParentAccount.Name,
                new JSTreeNodeState(true, false, false),
                new JSTreeNodeAAttr(String.valueOf(ultimateParentAccount.Id) == currentId ? 'font-weight:bold' : '')
                
            )
        );
        
      public String getJsonNode() {
        List<JSTreeLeave> listConItems = new List<JSTreeLeave>();
        listConItems.add(
            new JSTreeLeave(
                currentContact.Id,
                '#',
                currentContact.Name,
                new JSTreeNodeState(true, false, false),
                new JSTreeNodeAAttr(String.valueOf(IdCon.Id) == currentId ? 'font-weight:bold' : '')
                
            )
        );
        for (Account acc : AccountHierarchyServices.getAllChildren(new List<Account>{ultimateParentAccount})) {
            listItems.add(
                new JSTreeNode(
                    acc.Id,
                    acc.ParentId,
                    acc.Name,
                    new JSTreeNodeState(true, false, false),
                    new JSTreeNodeAAttr(String.valueOf(acc.Id) == currentId ? 'font-weight:bold' : '')
                )
            );
        }
        return JSON.serialize(listItems);
    }

     for (Contact con : AccountServices.getAllContact(new List<Contact>{Id})) {
            listConItems.add(
                new JSTreeNode(
                    con.Id,
                    con.AccountId,
                    con.Name,
                    new JSTreeNodeState(true, false, false),
                    new JSTreeNodeAAttr(String.valueOf(acc.Id) == currentId ? 'font-weight:bold' : '')
                )
            );
        }
        return JSON.serialize(listConItems);
    }

    /**
     * This class is used to generate jsTree node
     */
    @TestVisible private class JSTreeNode {
        public String id; //required
        public String parent; //required
        public String text; // node text
        public String icon; // string for custom icon
        public JSTreeNodeState state; // instance of JSTreeNodeState
        public Object li_attr; // attributes for the generated LI node
        public JSTreeNodeAAttr a_attr; // attributes for the generated A node
        
        public JSTreeNode(String id, String parent, String text, JSTreeNodeState state, JSTreeNodeAAttr a_attr) {
            this.id = id;
            this.parent = parent;
            this.text = text;
            this.state = state;
            this.a_attr = a_attr;
        }
    }

    @TestVisible private class JSTreeNodeState {
        public Boolean opened; // is the node open
        public Boolean disabled; // is the node disabled
        public Boolean selected; // is the node selected

        public JSTreeNodeState(Boolean opened, Boolean disabled, Boolean selected) {
            this.opened = opened;
            this.disabled = disabled;
            this.selected = selected;
        }
    }

    @TestVisible private class JSTreeNodeAAttr {
        public String style; // style of current node

        public JSTreeNodeAAttr(String style) {
            this.style = style;
        }
    }
    
}

Code is like this :
so,as per the account code i have created a method which is returning me currentcontact.Now i have to get contact that is for particular account id but i am stuck becuase i dont know from where this getJsonTree() is calling and if yes then how can i associate contact with it.because currently i have created a new method that getJsonNode() but i can use it only when i know that from where exactly its calling.could anybody help me on this.
Hi,as per my req able to print hierarchy on vf page with parent and its corresponding child account
/**
 * @description This is the controller class for HierarchyTree component
 * @author Valentyn Bilenkyi
 * @date 10/23/2015
 */
public without sharing class HierarchyTree {

    public static String currentId {get; set;}

    private static Account currentAccount {
        get {
            if (currentAccount == null) {
                currentAccount = [select Name, ParentId, UltimateParent__c From Account where Id = :currentId];
            }
            return currentAccount;
        }
        private set;
    }

    private static Account ultimateParentAccount {
        get {
            if (ultimateParentAccount == null) {
                if (currentAccount.UltimateParent__c != null) {
                    ultimateParentAccount = [select Name, ParentId, UltimateParent__c from Account where Id = :currentAccount.UltimateParent__c];
                } else {
                    ultimateParentAccount = currentAccount;
                }
               
            }
            return ultimateParentAccount;
        }
        private set;
    }
    
    /**
     * @description This methos is used to generate JSON data for jsTree component
     */
    public static String getJsonTree() {
        List<JSTreeNode> listItems = new List<JSTreeNode>();
        listItems.add(
            new JSTreeNode(
                ultimateParentAccount.Id,
                '#',
                ultimateParentAccount.Name,
                new JSTreeNodeState(true, false, false),
                new JSTreeNodeAAttr(String.valueOf(ultimateParentAccount.Id) == currentId ? 'font-weight:bold' : '')
                
            )
        );
        for (Account acc : AccountHierarchyServices.getAllChildren(new List<Account>{ultimateParentAccount})) {
            listItems.add(
                new JSTreeNode(
                    acc.Id,
                    acc.ParentId,
                    acc.Name,
                    new JSTreeNodeState(true, false, false),
                    new JSTreeNodeAAttr(String.valueOf(acc.Id) == currentId ? 'font-weight:bold' : '')
                )
            );
        }
        return JSON.serialize(listItems);
    }

    /**
     * This class is used to generate jsTree node
     */
    @TestVisible private class JSTreeNode {
        public String id; //required
        public String parent; //required
        public String text; // node text
        public String icon; // string for custom icon
        public JSTreeNodeState state; // instance of JSTreeNodeState
        public Object li_attr; // attributes for the generated LI node
        public JSTreeNodeAAttr a_attr; // attributes for the generated A node
        
        public JSTreeNode(String id, String parent, String text, JSTreeNodeState state, JSTreeNodeAAttr a_attr) {
            this.id = id;
            this.parent = parent;
            this.text = text;
            this.state = state;
            this.a_attr = a_attr;
        }
    }

    @TestVisible private class JSTreeNodeState {
        public Boolean opened; // is the node open
        public Boolean disabled; // is the node disabled
        public Boolean selected; // is the node selected

        public JSTreeNodeState(Boolean opened, Boolean disabled, Boolean selected) {
            this.opened = opened;
            this.disabled = disabled;
            this.selected = selected;
        }
    }

    @TestVisible private class JSTreeNodeAAttr {
        public String style; // style of current node

        public JSTreeNodeAAttr(String style) {
            this.style = style;
        }
    }
    
}

Now i have to associate corresponding contacts to that particular account on the hierarchy.I am clear with the query like :
[select Name, ParentId, UltimateParent__c, (SELECT Id, Name FROM Contacts) From Account where Id = :currentId]; But i am not sure how can use this query to in this particular code to get a desire result like account->account1->contact1,Contact2.Plesae help me out if any body is aware of this hierarchy concept.
Hi All,
Below is my code of VF page that i am rendering from another page via link :
Visualforce Page: Hierarchy_Clone 

<apex:page standardController="Account" showHeader="true" sideBar="true">
<apex:form > <c:HierarchyTree currId="{!Account.id}" />
</apex:form>
</apex:page>

But i am not getting a desire page because its not opning with sidebar and header.please suggest how to solve this issue.
Hi All,
Hi All,
Have a Req that in one process builder on Contact new task is created with following conditions :
1) Priority Picklist Normal
2) Status Picklist Completed
4) NameId Refrence [Contact].Id.
But on the creation of the new task the Business unit is picked by Contact Owner Business unit but i want it should be of task's owner Business unit.could any suggest how i can achieve it.
Could any one suggest is it possible?
 
Could any suggest that why i am getting this error :

Expression cannot be assigned at line -1 column -1

After saving this method 

 public static void TempAcc()
    {
       if( Account.RecordTypeId ='ParticularId')
        { 
          
               // system.debug('Account category needs to be blank when parent account is selected');
          
       }
     }




 
have a req that when i create new account that is RecordType ="Temporary Account" && Parent Account <> blank or Top Level account <> then make two field read only that is account category and account subcategory.Is it possible via validation rule?if yes,then how please suggest.
I have Req that when the new record is created that is temp account and if the parent account field is not blank then account category and subcategory must be blank.is this possible via validation rule?i yes then could any one suggest that how to do that
Hi All,
This is my code of VF page where i have already set sidebar and showheader still its not showing both the things and only showing data on blank page which is not looking fine.please suggest how can i solve this issue
<apex:page standardController="Account" sidebar="true" tabStyle="Account" showHeader="true" extensions="WithContactButtonController">

<apex:form >

<c:HierarchyTree currId="{!Account.id}" />

<input type="button" value="Back to Account" onclick="window.history.back()" /> <b><apex:commandLink action="{!doSomething1}" target="_top" value="IncludeContact" id="theButton"/></b>

 
Hi All,
I have a requirement that i am navigating from a link on VF page to another VF page now i want to create a link to go that partcular account from where i drilldown means on that particular account.Could any one suggest please how to do that?
Hi All,
Need help on an urgent issue.Requirement is to create a hierarchy of Parent Account its child and its corresponding contact.
Controller Class--->

public without sharing class HierarchyTree {

    public static String currentId {get; set;}

    private static Account currentAccount {
        get {
            if (currentAccount == null) {
                currentAccount = [select Name, ParentId, UltimateParent__c From Account where Id = :currentId];
            }
            return currentAccount;
        }
        private set;
    }

    private static Account ultimateParentAccount {
        get {
            if (ultimateParentAccount == null) {
                if (currentAccount.UltimateParent__c != null) {
                    ultimateParentAccount = [select Name, ParentId, UltimateParent__c from Account where Id = :currentAccount.UltimateParent__c];
                } else {
                    ultimateParentAccount = currentAccount;
                }
                currentAccount = [select Name, ParentId, UltimateParent__c From Account where Id = :currentId];
            }
            return currentAccount;
        }
        private set;
    }
    
    /**
     * @description This methos is used to generate JSON data for jsTree component
     */
    public static String getJsonTree() {
        List<JSTreeNode> listItems = new List<JSTreeNode>();
        listItems.add(
            new JSTreeNode(
                ultimateParentAccount.Id,
                '#',
                ultimateParentAccount.Name,
                new JSTreeNodeState(true, false, false),
                new JSTreeNodeAAttr(String.valueOf(ultimateParentAccount.Id) == currentId ? 'font-weight:bold' : '')
                
            )
        );
        for (Account acc : AccountHierarchyServices.getAllChildren(new List<Account>{ultimateParentAccount})) {
            listItems.add(
                new JSTreeNode(
                    acc.Id,
                    acc.ParentId,
                    acc.Name,
                    new JSTreeNodeState(true, false, false),
                    new JSTreeNodeAAttr(String.valueOf(acc.Id) == currentId ? 'font-weight:bold' : '')
                )
            );
        }
        return JSON.serialize(listItems);
    }

    /**
     * This class is used to generate jsTree node
     */
    @TestVisible private class JSTreeNode {
        public String id; //required
        public String parent; //required
        public String text; // node text
        public String icon; // string for custom icon
        public JSTreeNodeState state; // instance of JSTreeNodeState
        public Object li_attr; // attributes for the generated LI node
        public JSTreeNodeAAttr a_attr; // attributes for the generated A node
        
        public JSTreeNode(String id, String parent, String text, JSTreeNodeState state, JSTreeNodeAAttr a_attr) {
            this.id = id;
            this.parent = parent;
            this.text = text;
            this.state = state;
            this.a_attr = a_attr;
        }
    }

    @TestVisible private class JSTreeNodeState {
        public Boolean opened; // is the node open
        public Boolean disabled; // is the node disabled
        public Boolean selected; // is the node selected

        public JSTreeNodeState(Boolean opened, Boolean disabled, Boolean selected) {
            this.opened = opened;
            this.disabled = disabled;
            this.selected = selected;
        }
    }

    @TestVisible private class JSTreeNodeAAttr {
        public String style; // style of current node

        public JSTreeNodeAAttr(String style) {
            this.style = style;
        }
    }
    
}
 
Visualforce Component --->

<apex:component controller="HierarchyTree">
	
	<apex:attribute name="currId" description="This is the Account Id for displaying Acccount Hierarchy" type="String" required="true" assignTo="{!currentId}"/>

	<apex:outputPanel rendered="{! currId == null}" layout="none">
		<span style="font-size:16px; font-weight:bold; padding-top: 15px; display: inline-block;">{!$Label.AccountIdIsRequired}</span>
	</apex:outputPanel>

	<apex:outputPanel rendered="{! currId != null}" layout="none">

		<apex:stylesheet value="{!URLFOR($Resource.jsTree, 'dist/themes/default/style.min.css')}"/>
		<apex:includeScript value="{!URLFOR($Resource.jquery_1_11_3)}"/>
		<apex:includeScript value="{!URLFOR($Resource.jsTree, 'dist/jstree.min.js')}"/>

		<script>
			var j$ = jQuery.noConflict();

			j$(function(){

				j$('#jstree')
				// listen for event
				.on('changed.jstree', function (e, data) {
			        if( (typeof sforce != 'undefined') && sforce && (!!sforce.one) ) {
			            // Salesforce1 navigation
			            sforce.one.navigateToSObject('' + data.selected);
			        } else {
			        	// Set the window's parent URL using a javascript expression
			            window.top.location.href = '/' + data.selected;
			        }
				})
				// create the instance
				.jstree({
					'core' : {
						'data' : {!JsonTree}
					}
				});

			});
			
		</script>

		<div id="jstree"></div>

	</apex:outputPanel>

</apex:component>
 
Visualforce Page--->


<apex:page standardController="Account" > <apex:form >

<c:HierarchyTree currId="{!Account.id}" />


  <apex:outputLink value="https://bd2--cgkt.cs87.my.salesforce.com/001/o"><h1><b>Back to Account List</b></h1>!</apex:outputLink> 
<a href="?#"><font style="color:blue;">Exclude Contact</font></a> | <a href="?#"><font style="color:blue;">Include Contact</font></a>

</apex:form>

</apex:page>

Its Working fine and showing me the hierarchy of Account : 

Now my concern is i am not able to associate contact in the HierarchyTree first my thought was that i can make sub query or may be its call nested query like this in Hierarchy Tree Methods :

private static Account currentAccount {
        get {
            if (currentAccount == null) {
                currentAccount = [select Name, ParentId, UltimateParent__c,(select id,name from contacts) From Account where Id = :currentId];
            }
            return currentAccount;
        }
        private set;
    }

But its not returning me any row.then one suggestion i got is that i should use map for account and contact like 

 public Map<Id,Contact> contactsMap {
        get {
            if (contactsMap == null) {
                contactsMap = new Map<Id,Contact>();
                for (Account acc : [select Id, (select Id, FirstName, LastName from Contacts) from Account where Id = :currentId]) {
                    for (Contact c : acc.Contacts) {
                        contactsMap.put(c.Id, c);
                    }
                }
            }
            return contactsMap;
        }
        private set;
    }

But i am not sure how acutully i need to use map to get associate contact because that variable current account is also used in the another method to get parent account.Could someone suggeste me a proper way to associate contact in my current code.and how can i render this map to get hierarchy form in VF page means which method should i use to get contact and how i can use this method in <repeat> to get child in tree form.Please suggest its on Priority and not getting proper solution to show it in required format for contact. 
 
Hi,
Stuck in one requirement.in which at the time of create and update account one trgger has to be fired which will call class where i have to comapre login user with account's field that is Keymanager if success then need to assign a specfic permission set to the user.suppose there is 10-15 records where keymanager matches with login id then all have to have that permission like read,write and edit.need inputs
Hi,
I have a requirement to show hierarchy of accounts and its related account.I am able to show an account hierarachy on VF Page but i am not able to associate contacts to particular account.
Means ParentAccount->ChildAccount1->ChildContact1,ChildContact2->ChildAccount2->ChildContact1,ChildContact2.
public without sharing class HierarchyTree {

    public static String currentId {get; set;}

    private static Account currentAccount {
        get {
            if (currentAccount == null) {
                currentAccount = [select Name, ParentId, UltimateParent__c From Account where Id = :currentId];
            }
            return currentAccount;
        }
        private set;
    }

    private static Account ultimateParentAccount {
        get {
            if (ultimateParentAccount == null) {
                if (currentAccount.UltimateParent__c != null) {
                    ultimateParentAccount = [select Name, ParentId, UltimateParent__c from Account where Id = :currentAccount.UltimateParent__c];
                } else {
                    ultimateParentAccount = currentAccount;
                }
            }
            return ultimateParentAccount;
        }
        private set;
    }
    
    /**
     * @description This methos is used to generate JSON data for jsTree component
     */
    public static String getJsonTree() {
        List<JSTreeNode> listItems = new List<JSTreeNode>();
        listItems.add(
            new JSTreeNode(
                ultimateParentAccount.Id,
                '#',
                ultimateParentAccount.Name,
                new JSTreeNodeState(true, false, false),
                new JSTreeNodeAAttr(String.valueOf(ultimateParentAccount.Id) == currentId ? 'font-weight:bold' : '')
            )
        );
        for (Account acc : AccountHierarchyServices.getAllChildren(new List<Account>{ultimateParentAccount})) {
            listItems.add(
                new JSTreeNode(
                    acc.Id,
                    acc.ParentId,
                    acc.Name,
                    new JSTreeNodeState(true, false, false),
                    new JSTreeNodeAAttr(String.valueOf(acc.Id) == currentId ? 'font-weight:bold' : '')
                )
            );
        }
        return JSON.serialize(listItems);
    }

    /**
     * This class is used to generate jsTree node
     */
    @TestVisible private class JSTreeNode {
        public String id; //required
        public String parent; //required
        public String text; // node text
        public String icon; // string for custom icon
        public JSTreeNodeState state; // instance of JSTreeNodeState
        public Object li_attr; // attributes for the generated LI node
        public JSTreeNodeAAttr a_attr; // attributes for the generated A node
        
        public JSTreeNode(String id, String parent, String text, JSTreeNodeState state, JSTreeNodeAAttr a_attr) {
            this.id = id;
            this.parent = parent;
            this.text = text;
            this.state = state;
            this.a_attr = a_attr;
        }
    }

    @TestVisible private class JSTreeNodeState {
        public Boolean opened; // is the node open
        public Boolean disabled; // is the node disabled
        public Boolean selected; // is the node selected

        public JSTreeNodeState(Boolean opened, Boolean disabled, Boolean selected) {
            this.opened = opened;
            this.disabled = disabled;
            this.selected = selected;
        }
    }

    @TestVisible private class JSTreeNodeAAttr {
        public String style; // style of current node

        public JSTreeNodeAAttr(String style) {
            this.style = style;
        }
    }
    
}

Could any one know that how can i code to its related contacts on accounts.
Hi.
I am able to display Hierarchy of account and contact in vf page as per the req but its showing all the accounts which are there in my org it has to be specfic for only parent account and its corresponding contacts please help me out in it.if someone has a solution for it.
I have a requirement on which on click of the button i have to show the Hierarchy of accounts & its related contacts like :
Account1->Contact1,Contact2
Account2->Contact1,Contact2
Not finding a proper code to get this data in another VF Page.

Hi,

 

  I want to display the account and related contacts in the same visual force page. Actually i am achieved this like,

i am displayed the account names in first page block and am kept the command link for that account names if we click on that command link that will displayed the contacts related to that particular account in another pageblock. But, Now i want to display the account name first and all related contacts line by line. like that  i want to displat the contacts for all accounts. please any one help me how to solve this...

 

 

example

Maple Lawn Office III
8161 Maple Lawn Blvd
Fulton, MD 20759

Contact: Lydia Chandlee
G & R Management
840 First Street, NE
Washington, DC 20002

Phone: 301-807-0271
Fax: 202-898-0053
Email: 

Contract: No
Inspection Date: 4/6/2010
Inspection Type: Annual
5 Year Test: 2012
Reg/Serial #: HO1863
Service Company: Kone
Equipment Type: Passenger Hydraulic
Annual Price (per unit): $180
Semi-Annual Prince (per unit): $80

Maple Lawn Office III
8161 Maple Lawn Blvd
Fulton, MD 20759

Contact: Lydia Chandlee
G & R Management
840 First Street, NE
Washington, DC 20002

Phone: 301-807-0271
Fax: 202-898-0053
Email: 

Contract: Yes
Inspection Date: 4/6/2010
Inspection Type: Annual
5 Year Test: 2012
Reg/Serial #: HO1863
Service Company: Kone
Equipment Type: Passenger Hydraulic
Annual Price (per unit): $180
Semi-Annual Prince (per unit): $80

 

 

 

thanks,

yamini

  • March 29, 2011
  • Like
  • 0