• AMAN SINGH 24
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 10
    Replies
Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
List<Schema.ChildRelationship> C = R.getChildRelationships();
 system.debug(''+C);

this in not give either contact ,cases or opportunity so what kind of object it is returning?
 thanks in advance
<apex:page standardController="Contact" extensions="V_sg1" >
  <apex:form >
    <apex:pageBlock >
       <apex:pageBlockSection >
             <apex:inputField value="{!Contact.Lastname}" />
                
             <apex:inputField value="{!Contact.AccountID}" >
              <apex:actionSupport event="OnChange" action="{!phone}" />
                 </apex:inputField>
             <apex:inputField value="{!Contact.phone}" />
             <apex:inputField value="{!Contact.Fax}" />
      </apex:pageBlockSection>
      
    </apex:pageBlock>
  </apex:form>
</apex:page>


public class V_sg1 {

   

   public contact con;
    public V_sg1(ApexPages.StandardController controller) {
     con=(contact)controller.getRecord();
       

    }
     public PageReference phone() {
    Account acc=[select id,phone from Account where id=:con.AccountID];
    con.phone=acc.phone;
        return null;
    }


    
      }
rigger countcontacts on Contact (after delete, after insert, after undelete) {
02     
03    if(trigger.isAfter){
04         set<id> setOfAccId = new set<id>(); // create a set of contact account id
05       if(trigger.isInsert  || trigger.isUnDelete){
06            for(contact ocontact :trigger.New){   // play a for each loop at fill the set of id with account (id)
07                 setOfAccId.add(ocontact.AccountId);  
08            } 
09       }
10      if(trigger.isDelete){
11             for(contact ocontact :trigger.old){
12                setOfAccId.add(ocontact.AccountId);
13            }
14        } 
15         
16         // create a list for update Account
17         List<Account> accountUpdate = new List<Account>();
18         List<Account> getacc = [Select Number_of_contact__c, Id, (Select Id From contacts) FromAccount WHERE ID IN :setOfAccId];
19          for(Account acc :getacc){
20             Integer ppCount = 0;
21                for(contact ocon: acc.contacts){
22                 
23                          ppCount++ ;
24                
25                } // inner for loop close
26                 
27                if(acc.Number_of_contact__c != ppCount){
28                  
29                    acc.Number_of_contact__c = ppCount ;
30                    accountUpdate.add(acc);
31                 }
32          }// outer for loop close
33         
34        if(accountUpdate.size() > 0){
35           
36          update accountUpdate ;
37           
38          }
39     
      } // Trigger.isAfter closed
trigger C1 on Contact (after insert,after delete) {
    decimal x;
  If (trigger.IsInsert==true){
   
for(contact c:trigger.new){
    If(c.Account!=null){
         Account a =new account();
         a=[select   Number_of_contact__c from account where account.name=:c.account.name];
         if(a.Number_of_contact__c==null){
         a.Number_of_contact__c=0;}
         x=a.Number_of_contact__c ; 
         x=x+1;
         a.Number_of_contact__c=x;
         update a;
         
           }
        }
     }   
   }
Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
List<Schema.ChildRelationship> C = R.getChildRelationships();
 system.debug(''+C);

this in not give either contact ,cases or opportunity so what kind of object it is returning?
 thanks in advance
<apex:page standardController="Contact" extensions="V_sg1" >
  <apex:form >
    <apex:pageBlock >
       <apex:pageBlockSection >
             <apex:inputField value="{!Contact.Lastname}" />
                
             <apex:inputField value="{!Contact.AccountID}" >
              <apex:actionSupport event="OnChange" action="{!phone}" />
                 </apex:inputField>
             <apex:inputField value="{!Contact.phone}" />
             <apex:inputField value="{!Contact.Fax}" />
      </apex:pageBlockSection>
      
    </apex:pageBlock>
  </apex:form>
</apex:page>


public class V_sg1 {

   

   public contact con;
    public V_sg1(ApexPages.StandardController controller) {
     con=(contact)controller.getRecord();
       

    }
     public PageReference phone() {
    Account acc=[select id,phone from Account where id=:con.AccountID];
    con.phone=acc.phone;
        return null;
    }


    
      }
rigger countcontacts on Contact (after delete, after insert, after undelete) {
02     
03    if(trigger.isAfter){
04         set<id> setOfAccId = new set<id>(); // create a set of contact account id
05       if(trigger.isInsert  || trigger.isUnDelete){
06            for(contact ocontact :trigger.New){   // play a for each loop at fill the set of id with account (id)
07                 setOfAccId.add(ocontact.AccountId);  
08            } 
09       }
10      if(trigger.isDelete){
11             for(contact ocontact :trigger.old){
12                setOfAccId.add(ocontact.AccountId);
13            }
14        } 
15         
16         // create a list for update Account
17         List<Account> accountUpdate = new List<Account>();
18         List<Account> getacc = [Select Number_of_contact__c, Id, (Select Id From contacts) FromAccount WHERE ID IN :setOfAccId];
19          for(Account acc :getacc){
20             Integer ppCount = 0;
21                for(contact ocon: acc.contacts){
22                 
23                          ppCount++ ;
24                
25                } // inner for loop close
26                 
27                if(acc.Number_of_contact__c != ppCount){
28                  
29                    acc.Number_of_contact__c = ppCount ;
30                    accountUpdate.add(acc);
31                 }
32          }// outer for loop close
33         
34        if(accountUpdate.size() > 0){
35           
36          update accountUpdate ;
37           
38          }
39     
      } // Trigger.isAfter closed
trigger C1 on Contact (after insert,after delete) {
    decimal x;
  If (trigger.IsInsert==true){
   
for(contact c:trigger.new){
    If(c.Account!=null){
         Account a =new account();
         a=[select   Number_of_contact__c from account where account.name=:c.account.name];
         if(a.Number_of_contact__c==null){
         a.Number_of_contact__c=0;}
         x=a.Number_of_contact__c ; 
         x=x+1;
         a.Number_of_contact__c=x;
         update a;
         
           }
        }
     }   
   }