• jtjaard
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
I'm having a problem activating triggers. I'm able to upload the trigger, but cannot upload it in production.
I have created test code that came from the cook book, but the production account will not accept it.
When I was testing in the sandbox I did not encounter this issue, everything went smoothly.
Is it possible that the code provided in the cookbook is wrong? What am I doing wrong?
 
cookbook code from pg. 118:
 
Code:
public class leadDupePreventerTests{
static testMethod void testLeadDupPreventer() {
// First make sure there are no leads already in the system
// that have the email addresses used for testing
Set<String> testEmailAddress = new Set<String>();
testEmailAddress.add('test1@duptest.com');
testEmailAddress.add('test2@duptest.com');
testEmailAddress.add('test3@duptest.com');
testEmailAddress.add('test4@duptest.com');
testEmailAddress.add('test5@duptest.com');
System.assert([SELECT count() FROM Lead WHERE Email IN :testEmailAddress] == 0);
// Seed the database with some leads, and make sure they can
// be bulk inserted successfully.
Lead lead1 = new Lead(LastName='Test1', Company='Test1 Inc.',
Email='test1@duptest.com');
Lead lead2 = new Lead(LastName='Test2', Company='Test2 Inc.',
Email='test4@duptest.com');
Lead lead3 = new Lead(LastName='Test3', Company='Test3 Inc.',
Email='test5@duptest.com');
Lead[] leads = new Lead[] {lead1, lead2, lead3};
insert leads;
// Now make sure that some of these leads can be changed and
// then bulk updated successfully. Note that lead1 is not
// being changed, but is still being passed to the update
// call. This should be OK.
lead2.Email = 'test2@duptest.com';
lead3.Email = 'test3@duptest.com';
update leads;
// Make sure that single row lead duplication prevention works
// on insert.
Lead dup1 = new Lead(LastName='Test1Dup',
Company='Test1Dup Inc.',
Email='test1@duptest.com');
try {
insert dup1;
System.assert(false);
} catch (DmlException e) {
System.assert(e.getNumDml() == 1);
System.assert(e.getDmlIndex(0) == 0);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf(
'A lead with this email address already exists.') > -1);
}
// Make sure that single row lead duplication prevention works
// on update.
dup1 = new Lead(Id = lead1.Id, LastName='Test1Dup',
Company='Test1Dup Inc.',
Email='test2@duptest.com');
try {
update dup1;
System.assert(false);
} catch (DmlException e) {
System.assert(e.getNumDml() == 1);
System.assert(e.getDmlIndex(0) == 0);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf(
'A lead with this email address already exists.') > -1);
}
// Make sure that bulk lead duplication prevention works on
// insert. Note that the first item being inserted is fine,
// but the second and third items are duplicates. Note also
// that since at least one record insert fails, the entire
// transaction will be rolled back.
dup1 = new Lead(LastName='Test1Dup', Company='Test1Dup Inc.',
Email='test4@duptest.com');
Lead dup2 = new Lead(LastName='Test2Dup',
Company='Test2Dup Inc.',
Email='test2@duptest.com');
Lead dup3 = new Lead(LastName='Test3Dup',
Company='Test3Dup Inc.',
Email='test3@duptest.com');
Lead[] dups = new Lead[] {dup1, dup2, dup3};
try {
insert dups;
System.assert(false);
} catch (DmlException e) {
System.assert(e.getNumDml() == 2);
System.assert(e.getDmlIndex(0) == 1);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf(
'A lead with this email address already exists.') > -1);
System.assert(e.getDmlIndex(1) == 2);
System.assert(e.getDmlFields(1).size() == 1);
System.assert(e.getDmlFields(1)[0] == 'Email');
System.assert(e.getDmlMessage(1).indexOf(
'A lead with this email address already exists.') > -1);
}
// Make sure that bulk lead duplication prevention works on
// update. Note that the first item being updated is fine,
// because the email address is new, and the second item is
// also fine, but in this case it's because the email
// address doesn't change. The third case is flagged as an
// error because it is a duplicate of the email address of the
// first lead's value in the database, even though that value
// is changing in this same update call. It would be an
// interesting exercise to rewrite the trigger to allow this
// case. Note also that since at least one record update
// fails, the entire transaction will be rolled back.
dup1 = new Lead(Id=lead1.Id, Email='test4@duptest.com');
dup2 = new Lead(Id=lead2.Id, Email='test2@duptest.com');
dup3 = new Lead(Id=lead3.Id, Email='test1@duptest.com');
dups = new Lead[] {dup1, dup2, dup3};
try {
update dups;
System.assert(false);
} catch (DmlException e) {
System.debug(e.getNumDml());
System.debug(e.getDmlMessage(0));
System.assert(e.getNumDml() == 1);
System.assert(e.getDmlIndex(0) == 2);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf(
'A lead with this email address already exists.') > -1);
}
// Make sure that duplicates in the submission are caught when
// inserting leads. Note that this test also catches an
// attempt to insert a lead where there is an existing
// duplicate.
dup1 = new Lead(LastName='Test1Dup', Company='Test1Dup Inc.',
Email='test4@duptest.com');
dup2 = new Lead(LastName='Test2Dup', Company='Test2Dup Inc.',
Email='test4@duptest.com');
dup3 = new Lead(LastName='Test3Dup', Company='Test3Dup Inc.',
Email='test3@duptest.com');
dups = new Lead[] {dup1, dup2, dup3};
try {
insert dups;
System.assert(false);
} catch (DmlException e) {
System.assert(e.getNumDml() == 2);
System.assert(e.getDmlIndex(0) == 1);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf('Another new lead has the same email address.') > -1);
System.assert(e.getDmlIndex(1) == 2);
System.assert(e.getDmlFields(1).size() == 1);
System.assert(e.getDmlFields(1)[0] == 'Email');
System.assert(e.getDmlMessage(1).indexOf('A lead with this email address already exists.') > -1);
}
// Make sure that duplicates in the submission are caught when
// updating leads. Note that this test also catches an attempt
// to update a lead where there is an existing duplicate.
dup1 = new Lead(Id=lead1.Id, Email='test4@duptest.com');
dup2 = new Lead(Id=lead2.Id, Email='test4@duptest.com');
dup3 = new Lead(Id=lead3.Id, Email='test2@duptest.com');
dups = new Lead[] {dup1, dup2, dup3};
try {
update dups;
System.assert(false);
} catch (DmlException e) {
System.assert(e.getNumDml() == 2);
System.assert(e.getDmlIndex(0) == 1);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf(
'Another new lead has the same email address.') > -1);
System.assert(e.getDmlIndex(1) == 2);
System.assert(e.getDmlFields(1).size() == 1);
System.assert(e.getDmlFields(1)[0] == 'Email');
System.assert(e.getDmlMessage(1).indexOf(
'A lead with this email address already exists.') > -1);
}
}
}

 
The error I'm encountering in eclipse is stating that my trigger lacks code coverage, but production is not accepting the test code I have tried uploading. Any help would be appreciated.
Hi,
 
I was just wondering why the following code might not work? I'm working through eclipse; which isn't reporting an error, but when I check my account it hasn't been uploaded. When I remove the offending code everything compiles fine and I can see it in my force account.
 
Code:
[Select l.Boat__c, l.List_Price__c, l.Listing_Type__c, l.Name, l.RecordTypeId from Listing_Details__c l where l.boat__c =:myBoat AND l.RecordTypeId = 'foo'].List_Price__c);

 
myBoat is a string that holds the id.
 
Thanks for any help.

Hi,

I'm getting an unspecified compiler error with this code. I'm not really sure why it won't compile, any suggestions? Main error I see is: in class SalesReport at line -1 column -1

Code:
global class SalesReport {
        webservice static opportunity[] getAllOpportunities()
        {
         List<opportunity> opportunityList = new List<opportunity>();
         for (opportunity opp: [Select o.Amount, o.product__c, o.product__r.product_Condition__c, o.product_Condition__c, o.product_Marina__c, o.product_Model_Year__c, o.CloseDate, o.List_Price__c, o.CreatedDate, o.ExpectedRevenue,o.Id,o.LeadSource, o.Name, o.NextStep, o.OwnerId, o.Probability, o.StageName from Opportunity o limit 10])
          {
              opp.List_price__c = [select List_Price__c from Listing_Details__c where Listing_Details__c.product__c = :opp.product__c].List_price__c;
            
              opportunityList.add(opp);
          }
         
          return opportunityList;
        }
        static testmethod void testGetAllProducts()
        {
         List<opportunity> opp = getAllOpportunities();
         System.assertequals(10, opp.size());
        }
}

 




Message Edited by jtjaard on 01-04-2008 04:59 PM
I'm having a problem activating triggers. I'm able to upload the trigger, but cannot upload it in production.
I have created test code that came from the cook book, but the production account will not accept it.
When I was testing in the sandbox I did not encounter this issue, everything went smoothly.
Is it possible that the code provided in the cookbook is wrong? What am I doing wrong?
 
cookbook code from pg. 118:
 
Code:
public class leadDupePreventerTests{
static testMethod void testLeadDupPreventer() {
// First make sure there are no leads already in the system
// that have the email addresses used for testing
Set<String> testEmailAddress = new Set<String>();
testEmailAddress.add('test1@duptest.com');
testEmailAddress.add('test2@duptest.com');
testEmailAddress.add('test3@duptest.com');
testEmailAddress.add('test4@duptest.com');
testEmailAddress.add('test5@duptest.com');
System.assert([SELECT count() FROM Lead WHERE Email IN :testEmailAddress] == 0);
// Seed the database with some leads, and make sure they can
// be bulk inserted successfully.
Lead lead1 = new Lead(LastName='Test1', Company='Test1 Inc.',
Email='test1@duptest.com');
Lead lead2 = new Lead(LastName='Test2', Company='Test2 Inc.',
Email='test4@duptest.com');
Lead lead3 = new Lead(LastName='Test3', Company='Test3 Inc.',
Email='test5@duptest.com');
Lead[] leads = new Lead[] {lead1, lead2, lead3};
insert leads;
// Now make sure that some of these leads can be changed and
// then bulk updated successfully. Note that lead1 is not
// being changed, but is still being passed to the update
// call. This should be OK.
lead2.Email = 'test2@duptest.com';
lead3.Email = 'test3@duptest.com';
update leads;
// Make sure that single row lead duplication prevention works
// on insert.
Lead dup1 = new Lead(LastName='Test1Dup',
Company='Test1Dup Inc.',
Email='test1@duptest.com');
try {
insert dup1;
System.assert(false);
} catch (DmlException e) {
System.assert(e.getNumDml() == 1);
System.assert(e.getDmlIndex(0) == 0);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf(
'A lead with this email address already exists.') > -1);
}
// Make sure that single row lead duplication prevention works
// on update.
dup1 = new Lead(Id = lead1.Id, LastName='Test1Dup',
Company='Test1Dup Inc.',
Email='test2@duptest.com');
try {
update dup1;
System.assert(false);
} catch (DmlException e) {
System.assert(e.getNumDml() == 1);
System.assert(e.getDmlIndex(0) == 0);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf(
'A lead with this email address already exists.') > -1);
}
// Make sure that bulk lead duplication prevention works on
// insert. Note that the first item being inserted is fine,
// but the second and third items are duplicates. Note also
// that since at least one record insert fails, the entire
// transaction will be rolled back.
dup1 = new Lead(LastName='Test1Dup', Company='Test1Dup Inc.',
Email='test4@duptest.com');
Lead dup2 = new Lead(LastName='Test2Dup',
Company='Test2Dup Inc.',
Email='test2@duptest.com');
Lead dup3 = new Lead(LastName='Test3Dup',
Company='Test3Dup Inc.',
Email='test3@duptest.com');
Lead[] dups = new Lead[] {dup1, dup2, dup3};
try {
insert dups;
System.assert(false);
} catch (DmlException e) {
System.assert(e.getNumDml() == 2);
System.assert(e.getDmlIndex(0) == 1);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf(
'A lead with this email address already exists.') > -1);
System.assert(e.getDmlIndex(1) == 2);
System.assert(e.getDmlFields(1).size() == 1);
System.assert(e.getDmlFields(1)[0] == 'Email');
System.assert(e.getDmlMessage(1).indexOf(
'A lead with this email address already exists.') > -1);
}
// Make sure that bulk lead duplication prevention works on
// update. Note that the first item being updated is fine,
// because the email address is new, and the second item is
// also fine, but in this case it's because the email
// address doesn't change. The third case is flagged as an
// error because it is a duplicate of the email address of the
// first lead's value in the database, even though that value
// is changing in this same update call. It would be an
// interesting exercise to rewrite the trigger to allow this
// case. Note also that since at least one record update
// fails, the entire transaction will be rolled back.
dup1 = new Lead(Id=lead1.Id, Email='test4@duptest.com');
dup2 = new Lead(Id=lead2.Id, Email='test2@duptest.com');
dup3 = new Lead(Id=lead3.Id, Email='test1@duptest.com');
dups = new Lead[] {dup1, dup2, dup3};
try {
update dups;
System.assert(false);
} catch (DmlException e) {
System.debug(e.getNumDml());
System.debug(e.getDmlMessage(0));
System.assert(e.getNumDml() == 1);
System.assert(e.getDmlIndex(0) == 2);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf(
'A lead with this email address already exists.') > -1);
}
// Make sure that duplicates in the submission are caught when
// inserting leads. Note that this test also catches an
// attempt to insert a lead where there is an existing
// duplicate.
dup1 = new Lead(LastName='Test1Dup', Company='Test1Dup Inc.',
Email='test4@duptest.com');
dup2 = new Lead(LastName='Test2Dup', Company='Test2Dup Inc.',
Email='test4@duptest.com');
dup3 = new Lead(LastName='Test3Dup', Company='Test3Dup Inc.',
Email='test3@duptest.com');
dups = new Lead[] {dup1, dup2, dup3};
try {
insert dups;
System.assert(false);
} catch (DmlException e) {
System.assert(e.getNumDml() == 2);
System.assert(e.getDmlIndex(0) == 1);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf('Another new lead has the same email address.') > -1);
System.assert(e.getDmlIndex(1) == 2);
System.assert(e.getDmlFields(1).size() == 1);
System.assert(e.getDmlFields(1)[0] == 'Email');
System.assert(e.getDmlMessage(1).indexOf('A lead with this email address already exists.') > -1);
}
// Make sure that duplicates in the submission are caught when
// updating leads. Note that this test also catches an attempt
// to update a lead where there is an existing duplicate.
dup1 = new Lead(Id=lead1.Id, Email='test4@duptest.com');
dup2 = new Lead(Id=lead2.Id, Email='test4@duptest.com');
dup3 = new Lead(Id=lead3.Id, Email='test2@duptest.com');
dups = new Lead[] {dup1, dup2, dup3};
try {
update dups;
System.assert(false);
} catch (DmlException e) {
System.assert(e.getNumDml() == 2);
System.assert(e.getDmlIndex(0) == 1);
System.assert(e.getDmlFields(0).size() == 1);
System.assert(e.getDmlFields(0)[0] == 'Email');
System.assert(e.getDmlMessage(0).indexOf(
'Another new lead has the same email address.') > -1);
System.assert(e.getDmlIndex(1) == 2);
System.assert(e.getDmlFields(1).size() == 1);
System.assert(e.getDmlFields(1)[0] == 'Email');
System.assert(e.getDmlMessage(1).indexOf(
'A lead with this email address already exists.') > -1);
}
}
}

 
The error I'm encountering in eclipse is stating that my trigger lacks code coverage, but production is not accepting the test code I have tried uploading. Any help would be appreciated.
Hi,
 
I was just wondering why the following code might not work? I'm working through eclipse; which isn't reporting an error, but when I check my account it hasn't been uploaded. When I remove the offending code everything compiles fine and I can see it in my force account.
 
Code:
[Select l.Boat__c, l.List_Price__c, l.Listing_Type__c, l.Name, l.RecordTypeId from Listing_Details__c l where l.boat__c =:myBoat AND l.RecordTypeId = 'foo'].List_Price__c);

 
myBoat is a string that holds the id.
 
Thanks for any help.
Another quick question.  When I have duplicate contact information between users, how is this handled by Sales Force?  For example, if I have 3 or 4 folks upload their contact lists to Sales Forces, there will be a number of overlaping contacts between the 3 or 4 uploads.  How does Sales Force eliminate the dupes, or does it?  Or are all contacts tracked by employee doing the upload?
 
Thanks in advance,
 
Bing