• king kullai
  • NEWBIE
  • -1 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 9
    Replies
Hi All,
   i have a requirement on account to contact objects, in that in contacts object have once check box export=true , if data  have changed in  account  or contact objects then export has to be false( export =false.  ) in contact object. 
   can any one have best solution or code for it could u share with us
   
Thanks All
Hello,

I would like to create a list of custom objects on a home page layout. I understand that I need to make a home page component, I just need help building the APEX VF page.

How do I create a list of custom objects? I've done this before with opportunities by going to the Opportunity home page and creating a new ListView, but custom objects don't seem to have this luxury. Any suggestions are appreciated! 

Thanks!
trigger ParentChildcase on Case (before update) {

String QueueDeveloperName='Welcome_Call_Queue';
Group CaseQueue=[select id,name,DeveloperName from group where type='Queue' AND developername='Welcome_Call_Queue'];
system.debug('*****CaseQueue:'+CaseQueue);




List<Case> listCase = [select Id,parentId,status from case where parentId != null  ];
////List<Queues> listqueue = [select Id from Queues where name = 'Welcome_Call_Queue'];
system.debug('listCase'+listCase);
map<Id,list<Case>> mapCase = new map<Id,list<Case>>();
    for(Case objCase : listCase){
         if(objCase.status != 'Closed'){
            List<Case> listCasemap = new List<Case>();
            if(mapCase.containskey(objCase.parentId))
                listCasemap = mapCase.get(objCase.parentId);
            listCasemap.add(objCase);
            mapCase.put(objCase.parentId,listCasemap);
         }
    }
    system.debug('mapCase'+mapCase);
    for(case caseObj:Trigger.New){
          if(caseObj.parentId == null && caseObj.Status == 'Closed'){
            if(mapCase.containskey(caseObj.Id)){
                List<Case> listCasemap = mapCase.get(caseObj.Id);
                if(listCasemap.size() != 0){
                    caseObj.addError('OPEN CHILD CASES ARE PRESENT.PLEASE CLOSE THESE CASES');
                }               
            }
          }
        system.debug('caseObj.Owner.Name'+caseObj.Owner.Name);
        if(caseObj.OwnerID == CaseQueue.id && caseObj.Status == 'Closed'){
            caseObj.addError('PLEASE CHANGE THE CASE OWNER TO CLOSE THE CASE');
        }          
      }   
}

 
Hi,

Can any one explain me exactly when to go for before insert and after insert with an example.

Regards,
Suresh.
  • April 01, 2015
  • Like
  • 0
trigger Example123 on Case (before insert, before update) {   

  Set<Id> accountIdSet = new Set<Id>();

  for(Case caseForVarRecord : Trigger.new){

    if(caseForVarRecord.AccountId != null ){
      accountIdSet .add(caseForVarRecord.AccountId);
    }        
  }
  
  map<Id,Account> accountMap =  new Map<Id,Account>([Select Id, Ownerid from Account where Id =: accountIdSet ]);

  for (Case c: Trigger.new){ 
    if(c.AdditionalCon__c ==null ){
      c.AdditionalCon__c = accountMap.get(c.AccountId).OwnerId;               
    }
  } 
}
I'm trying to create a formula that will send email alert when Account Type equals Customer and the Account Owner Changes. Here is what I have tried which is not working so any help would be appreciated.

IF(ISPICKVAL(Type, "Customer") AND( ISCHANGED(OwnerId)
Not able to retrieve fields from contact.

<apex:page standardController="contact" recordSetVar="contacts" >
<apex:form >
<apex:pageBlock title="Viewing Contacts">
<apex:pageBlockTable value="{!contacts}" var="c">
<apex:column value="{!c.name}"/>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
hi all,
i need to write test class for this trigger. Please give some idea


trigger accountTestTrggr  on Account (before insert,before update) {
 List<Account> accountsWithContacts = [select id, name,(select id,firstname, lastname,Description from Contacts) from Account where Id IN :Trigger.newMap.keySet()];         
 List<Contact> contactsToUpdate = new List<Contact>{};
    for(Account a: accountsWithContacts){
    for(Contact c: a.Contacts){
    c.Description=c.firstname+c.lastname;
    contactsToUpdate.add(c);
       }
}
update contactsToUpdate;
}
I have a unit test that is running successfully however I cannot open the results in the developer console. Getting an error: Failed
to load data Log from Salesforce.com: Other unit test do open up in the devveloper console so I'm not sure why these recent test do not.. Any ideas on what could be casuing this ? 

User-added image

Unit test:
@isTest
private class UnitTest_Driver {
  
  //Test coverage for New Driver Creation (VF page) 
  static testmethod void testNewDriver() {

      
    Account acct = UtilityAudit.getAccount();
    insert acct;
    Audit__c audit = UtilityAudit.getAudit(acct.Id);
    insert audit; 
    Auto_Audit_Sample_Policy__c sample = UtilityAudit.getAuto_Audit_Sample_Policy(audit.Id);
    insert sample;
     Auto_Drivers__c driver = UtilityAudit.getAuto_Drivers(sample.Id);
     //driver.Driver_Birth_Year__c = '9999';
    insert driver;

    //initiate the VF page
    PageReference pageRef = Page.PROD_Audit_Auto_DriverSample_New;
    Test.setcurrentPage(pageref);
       //these parms are passed via custom button ?accId={!Audit__c.Id}&sampleId={!Auto_Audit_Sample_Policy__c.Id}
    Apexpages.currentPage().getParameters().put('AccId', audit.Id);
    Apexpages.currentPage().getParameters().put('sampleId', sample.Id);
 
    //create standard controller and extended controller instance
    ApexPages.StandardController sc = new ApexPages.standardController(driver);
    ParentChildExtensionDRIVERsample_New testDriverPage = new ParentChildExtensionDRIVERsample_New(sc);


    //save the controller to get the URL
    String testPage = sc.save().getUrl();
    System.debug('TestPage result:' + testPage);

    // Verify that page fails without parameters
    // System.assertEquals('/apex/failure?error=noParam', testPage);



    //TODO
    String accID=ApexPages.currentPage().getParameters().get('AccId');
    System.debug('accID: ' + accID);
    String sampleID=ApexPages.currentPage().getParameters().get('sampleId');
    System.debug('sampleID: ' + sampleID);
    
    List< Audit__c> drivers = [ select Id, Driver_Information__c, Age__c, Gender__c, Marital_Status__c, Named_Insured_Add_Driver__c, Occupation__c, Business_Use__c, MVR_Violations__c, Credit_Scoring__c                
         from Audit__c 
         where Id = :ApexPages.currentPage().getParameters().get('accId')]; 
    System.debug('Age : ' + drivers[0].Age__c );
    
  } 
}