• Nagarjun T
  • NEWBIE
  • 60 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 12
    Replies
two objects

1) Customer__c
2) Payment__c

Fields for Customer__c
1) FirstName__c
2) LastName__c
3) Phone__c
4) Email__c
5) Amount__c

Fields for Payment__c
1) Mode__c
2) Amount__c
3) Customer__c  : Lookup(customer)
Customer__c
     firstName__c
     LastName__c
     Phone__c
     Email__c
     Amount__c

Payment__c
        MOde__c
        Amount__c
        Customer__c  : Lookup(Customer)
Hello, Here iam representing my code for this class i have to create @Test class

public class TRN_AccountDetailPage_Ctrl {
    //Getter setter //Property
    public Account acct{Get;Set;}
    //Constructor same sa class name
    public TRN_AccountDetailPage_Ctrl(){
    
        string strid = apexpages.currentpage().getparameters().get('id');
         if(strid !=''&& strid !=null){
          acct =[select id,name,phone,Accountnumber,Billingcity,billingcountry,billingstreet,fax from Account where id=:strid];
         }
     }
}
I Need to create contact record automatically when account record is created 
Hi everyone,
       before deleting the account iam trying to copy the account data to another custom object, how can i create the trigger can any one help this topic 
trigger contaccupdatetrigger on Contact (after update)
{
    List<contact> lstConUpdate = new List<Contact>();
    set<Id> sAccId = new set<Id>();
    for(Contact con: trigger.new){
        saccId.add(con.accountId);
    }
    List<Account> lstaccount = [select fax, (select fax from contacts) from account where id IN: saccId];
    for(Account acc: lstAccount){
        for(Contact con: acc.contacts){
            con.fax = acc.fax;
            lstConUpdate.add(con);
        }
    }
    if(lstConUpdate.size() > 0){
        update lstConUpdate;
    }   
}

Error :--
           Error:Apex trigger contaccupdatetrigger caused an unexpected exception, contact your administrator: contaccupdatetrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0037F000002JwNEQA0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, contaccupdatetrigger: maximum trigger depth exceeded Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate: []: Trigger.contaccupdatetrigger: line 16, column 1
<apex:page controller="schoollistpage_controller" sidebar="false">
<apex:sectionHeader title="Schools List"/>
    <apex:form >
        <apex:pageBlock >
                <apex:commandButton value="Hyd Location" action="{!hydmthd}"/>
        
            <apex:pageBlockTable value="{!schlst}" var="sch">
                <apex:column value="{!sch.name}"/>
                    <apex:commandLink onclick="window.open('/apex/schooldetailpage_controller?id={!sch.ID}')">
                    {!sch.Name} 
                    </apex:commandLink>
                
                <apex:column value="{!sch.Location__c}"/>
                <apex:column value="{!sch.Principal__c}"/>
                <apex:column value="{!sch.Total_Students__c}"/>
            
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public class apex4 {

    public PageReference Save() {
        return null;
    }

contact con=new contact();

    public contact newcon{get;set;}
    
    public apex4(){
    newcon=new contact();
    }
   public pagereference save(){
   contact coninsert=new contact();
    coninsert.lastname=newcon.name;
    coninsert.phone=newcon.phone;
    insert coninsert;
    
    pagereference pageref = new pagereference('/'+con.id);
    return pageref;
   
   } 
}

 account acc;

acc = new account;

acc.name='suresh';
acc.industry='telecom'
acc.rating='9';
acc.phone='9246100100';

insert acc;

system.debug('account id....'+acc.id);
HI All, 
            what is the command link action for new pop-up window in visualforce,

<apex:page setup="false" sidebar="false" standardController="contact" recordSetVar="ContactList">
<apex:form >
    <apex:commandButton value="New Contact" action="/apex/customcontacts"/>
<apex:pageBlock >    
            <apex:pageBlockTable value="{!Contactlist}" var="A"> 
                    <apex:column headerValue="Contact Name"> 
                    <apex:commandLink action="/apex/customcontactsdetailedpage?id={!A.id}" target="_blank">
                    {!A.Name}
                    </apex:commandLink>
                </apex:column> 
            <apex:column value="{!A.ID}"/>
            <apex:column value="{!A.Phone}"/>
            <apex:column value="{!A.mailingcountry}"/>
            
            </apex:pageBlockTable> >
 </apex:pageBlock>           
            </apex:form>
  </apex:page>
<apex:page setup="false" sidebar="false" standardController="contact" recordSetVar="ContactList">
<apex:form >
    <apex:commandButton value="New Contact" action="/apex/customcontacts"/>
<apex:pageBlock >    
            <apex:pageBlockTable value="{!Contactlist}" var="A"> 
                    <apex:column headerValue="ConUser-added imagetact Name"> 
                    <apex:commandLink action="/apex/customcontactsdetailedpage?id={!A.id}" target="_blank" >
                    {!A.Name}
                    </apex:commandLink>
                </apex:column> 
            <apex:column value="{!A.ID}"/>
            <apex:column value="{!A.Phone}"/>
            <apex:column value="{!A.mailingcountry}"/>
            
            </apex:pageBlockTable> >
 </apex:pageBlock>           
            </apex:form>
  </apex:page>
I Need to create contact record automatically when account record is created 
Hi everyone,
       before deleting the account iam trying to copy the account data to another custom object, how can i create the trigger can any one help this topic 
trigger contaccupdatetrigger on Contact (after update)
{
    List<contact> lstConUpdate = new List<Contact>();
    set<Id> sAccId = new set<Id>();
    for(Contact con: trigger.new){
        saccId.add(con.accountId);
    }
    List<Account> lstaccount = [select fax, (select fax from contacts) from account where id IN: saccId];
    for(Account acc: lstAccount){
        for(Contact con: acc.contacts){
            con.fax = acc.fax;
            lstConUpdate.add(con);
        }
    }
    if(lstConUpdate.size() > 0){
        update lstConUpdate;
    }   
}

Error :--
           Error:Apex trigger contaccupdatetrigger caused an unexpected exception, contact your administrator: contaccupdatetrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0037F000002JwNEQA0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, contaccupdatetrigger: maximum trigger depth exceeded Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate Contact trigger event AfterUpdate: []: Trigger.contaccupdatetrigger: line 16, column 1