• Sunchaser
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies

Hi everyone,
 
I am trying to create a custom new Account/Contact (Both Account and Contacts will be created from the same page with a custom controller) .
 
The tricky part is I don't want to hardcode the form fields into the page, customer wants to add/remove fields in the future. So we want the form fields to be picked from Account and Contact Fieldsets.

 

I have been experimenting with the visualforce code for a while now, but I haven't been able to achieve getting the Fieldsets into the Form yet.
 
Is this a possible task?
   
Thanks a lot!

Hi,

 

We are using the Common Ground Donor Management App on our SalesForce instance.  Besides that we have couple of triggers.  Common Ground has a new upgrade and suddenly our test class begin giving the following error message:

 

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, cv.OpportunityAll: execution of AfterInsert caused by: cv.Utils.DesignationException: Error - Please create a default Designation. (cv) : []

 

Stack Trace: Class.UnitTests.testOppsBatch: line 124, column 3 External entry point

 

 

And the code that causes the problem is this:

 

static testmethod void testAcctConBatch() {
    Map<String, Id> recTypesRev = new Map<String, Id>();
    
    //Build a reversed map so that the record type name becomes the Key and the id is the Value.
    for(RecordType rec :[select id, DeveloperName from RecordType]) {
      recTypesRev.put(rec.DeveloperName, rec.Id);
    }

    Account acct1 = new Account(Name = 'Apex Test Household', RecordTypeId = recTypesRev.get('Household'));
    insert acct1;
    
    Contact con1 = new Contact(FirstName = 'Apex Household', LastName = 'Contact1', AccountId = acct1.Id, YTD_Donation_Amount__c = 10,
     Remaining_Recurring_Amount__c = 10, RecordTypeId = recTypesRev.get('HouseholdContact'));
    insert con1;

    Contact con2 = new Contact(FirstName = 'Apex Household', LastName = 'Contact2', AccountId = acct1.Id, YTD_Donation_Amount__c = 20,
     Remaining_Recurring_Amount__c = 20, RecordTypeId = recTypesRev.get('HouseholdContact'));
    insert con2;

    //Test acctConBatch.
    Test.startTest();
    CalcYTDAccountContactBatch acctConBatch = new CalcYTDAccountContactBatch();
    acctConBatch.queryAcctCon = 'select YTD_All_Contacts__c, (select YTD_Grand_Total__c from Contacts) from Account where Name = \'Apex Test Household\'';
    Id batchprocessID = Database.executeBatch(acctConBatch);
    Test.stopTest();
    
    Account resultAcct = [select YTD_All_Contacts__c from Account where Id = :acct1.Id];
    system.assertEquals(resultAcct.YTD_All_Contacts__c, 60);

  }

 

the following line causes the error:

 

   Contact con2 = new Contact(FirstName = 'Apex Household', LastName = 'Contact2', AccountId = acct1.Id, YTD_Donation_Amount__c = 20,
     Remaining_Recurring_Amount__c = 20, RecordTypeId = recTypesRev.get('HouseholdContact'));
    insert con2;

Since Common Ground is a managed package , I know that this might be a long shot, but still I would appreciate any suggestions or possible fixes.

 

 

Thank you!

 

 

Hi,

 

I am new with Apex, I wrote the following code..  Normally this code compares the myset set values with the BillingPostalCode field and if they match it updates the field (change my custom field "locality" to "Philadelphia") . This code works, if the field it is updating is a default Account field. For example it changes Account Name field without any errors but it doesn't update my custom field.   Is there an extra step needed for custom fields that I created? 

 

I would really appreciate if anyone can tell me what is the problem..

 

Thanks!

 

   

 

trigger testtrigger on Account (Before insert, before update) {
//populate set
Set<String> myset = new Set<String>{'08759','08757','08753','08721','08731','08758'}; 
//iterate through Trigger.new
    for(Account A : Trigger.new){
//Check if Account field is in myset
        if(myset.contains(A.BillingPostalCode){

            A.Locality= 'Philadelphia';
        }  
    }   
}

 

Hi,

 

I am new with Apex and, I was wondering if anyone can tell me what is wrong with the following code:

 

I was trying to compare the zip codes in the myset set with the BillingPostalCode of the account records.  Even though the code didn't give any errors, when I run it,  I get "maximum trigger depth exceeded" error. I guess  there is a problem with the loop and it is trying to run the same line over an over. 

 

 

trigger testtrigger on Account (After Insert, after update) {

Set<String> myset = new Set<String>{'87543','08502', '07541'}; 



String s = 'Tester'; 


for (Account accs : [select id, name,BillingPostalCode from account where BillingPostalCode in :myset]){ 
  


accs.Name = 'test successful';

update accs;

       }
    
}

 

Help will be  really appreciated.

Thanks!

 

Hi everyone,
 
I am trying to create a custom new Account/Contact (Both Account and Contacts will be created from the same page with a custom controller) .
 
The tricky part is I don't want to hardcode the form fields into the page, customer wants to add/remove fields in the future. So we want the form fields to be picked from Account and Contact Fieldsets.

 

I have been experimenting with the visualforce code for a while now, but I haven't been able to achieve getting the Fieldsets into the Form yet.
 
Is this a possible task?
   
Thanks a lot!

Hi,

 

We are using the Common Ground Donor Management App on our SalesForce instance.  Besides that we have couple of triggers.  Common Ground has a new upgrade and suddenly our test class begin giving the following error message:

 

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, cv.OpportunityAll: execution of AfterInsert caused by: cv.Utils.DesignationException: Error - Please create a default Designation. (cv) : []

 

Stack Trace: Class.UnitTests.testOppsBatch: line 124, column 3 External entry point

 

 

And the code that causes the problem is this:

 

static testmethod void testAcctConBatch() {
    Map<String, Id> recTypesRev = new Map<String, Id>();
    
    //Build a reversed map so that the record type name becomes the Key and the id is the Value.
    for(RecordType rec :[select id, DeveloperName from RecordType]) {
      recTypesRev.put(rec.DeveloperName, rec.Id);
    }

    Account acct1 = new Account(Name = 'Apex Test Household', RecordTypeId = recTypesRev.get('Household'));
    insert acct1;
    
    Contact con1 = new Contact(FirstName = 'Apex Household', LastName = 'Contact1', AccountId = acct1.Id, YTD_Donation_Amount__c = 10,
     Remaining_Recurring_Amount__c = 10, RecordTypeId = recTypesRev.get('HouseholdContact'));
    insert con1;

    Contact con2 = new Contact(FirstName = 'Apex Household', LastName = 'Contact2', AccountId = acct1.Id, YTD_Donation_Amount__c = 20,
     Remaining_Recurring_Amount__c = 20, RecordTypeId = recTypesRev.get('HouseholdContact'));
    insert con2;

    //Test acctConBatch.
    Test.startTest();
    CalcYTDAccountContactBatch acctConBatch = new CalcYTDAccountContactBatch();
    acctConBatch.queryAcctCon = 'select YTD_All_Contacts__c, (select YTD_Grand_Total__c from Contacts) from Account where Name = \'Apex Test Household\'';
    Id batchprocessID = Database.executeBatch(acctConBatch);
    Test.stopTest();
    
    Account resultAcct = [select YTD_All_Contacts__c from Account where Id = :acct1.Id];
    system.assertEquals(resultAcct.YTD_All_Contacts__c, 60);

  }

 

the following line causes the error:

 

   Contact con2 = new Contact(FirstName = 'Apex Household', LastName = 'Contact2', AccountId = acct1.Id, YTD_Donation_Amount__c = 20,
     Remaining_Recurring_Amount__c = 20, RecordTypeId = recTypesRev.get('HouseholdContact'));
    insert con2;

Since Common Ground is a managed package , I know that this might be a long shot, but still I would appreciate any suggestions or possible fixes.

 

 

Thank you!

 

 

Hi,

 

I am new with Apex, I wrote the following code..  Normally this code compares the myset set values with the BillingPostalCode field and if they match it updates the field (change my custom field "locality" to "Philadelphia") . This code works, if the field it is updating is a default Account field. For example it changes Account Name field without any errors but it doesn't update my custom field.   Is there an extra step needed for custom fields that I created? 

 

I would really appreciate if anyone can tell me what is the problem..

 

Thanks!

 

   

 

trigger testtrigger on Account (Before insert, before update) {
//populate set
Set<String> myset = new Set<String>{'08759','08757','08753','08721','08731','08758'}; 
//iterate through Trigger.new
    for(Account A : Trigger.new){
//Check if Account field is in myset
        if(myset.contains(A.BillingPostalCode){

            A.Locality= 'Philadelphia';
        }  
    }   
}

 

Hi,

 

I am new with Apex and, I was wondering if anyone can tell me what is wrong with the following code:

 

I was trying to compare the zip codes in the myset set with the BillingPostalCode of the account records.  Even though the code didn't give any errors, when I run it,  I get "maximum trigger depth exceeded" error. I guess  there is a problem with the loop and it is trying to run the same line over an over. 

 

 

trigger testtrigger on Account (After Insert, after update) {

Set<String> myset = new Set<String>{'87543','08502', '07541'}; 



String s = 'Tester'; 


for (Account accs : [select id, name,BillingPostalCode from account where BillingPostalCode in :myset]){ 
  


accs.Name = 'test successful';

update accs;

       }
    
}

 

Help will be  really appreciated.

Thanks!