• MNaethler
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 21
    Replies

Hey guys, i got a code coverage from 89%.

 

Well i want to max it to 100%, just for myself, but i dont know how to to improve the code coverage for nested if statements, can anyone give me an idea?

 

see code below 

the underlined is not covered, which i want to get covered

 

trigger : 

 

trigger preventDuplicateLeadEntriesByEmailAndPhoneAndMobilePhone on Lead (before insert, before update){
    Map<String, Lead> leadMap = new Map<String, Lead>();
    for (Lead lead : System.Trigger.new){
        // To make sure we don't treat an email address, phone or mobilephone number 
        // that isn't changing during an update as a duplicate.   
        if ((lead.Email != null) && (System.Trigger.isInsert || (lead.Email != System.Trigger.oldMap.get(lead.Id).Email))){
            if (leadMap.containsKey(lead.Email)){
                lead.Email.addError('Another lead has the same email address.');            } 
            else{
                leadMap.put(lead.Email, lead);
            }
        }  
        if ((lead.Phone != null) && (System.Trigger.isInsert || (lead.Phone != System.Trigger.oldMap.get(lead.Id).Phone))){
            if (leadMap.containsKey(lead.Phone)){
                lead.Phone.addError('Another lead has the same Phone number.');            } 
            else{
                leadMap.put(lead.Phone, lead);
            }
        }
        if ((lead.Mobilephone__c != null) && (System.Trigger.isInsert || (lead.Mobilephone__c != System.Trigger.oldMap.get(lead.Id).Mobilephone__c))){
            if (leadMap.containsKey(lead.Mobilephone__c)){
                lead.Mobilephone__c.addError('Another lead has the same Mobilephone number.');            } 
            else{
                leadMap.put(lead.Mobilephone__c, lead);
            }
        }
        
        //To make sure that the customer has entered the streetnumber
        if (lead.Streetnumber__c == null){
        	lead.Streetnumber__c.addError('Please review your streetadress and paste your streetnumber here');
        }
        
        /*
        //To make sure that the Street and streetnumber isnt äquivalent to an existing phone or mobilephone number  
        */
                
        // To make sure that the customer has entered a mobilephone or telephon number or a address to contact him later
        if (lead.LastName == null && lead.Street == null && lead.Mobilephone__c == null && lead.Phone == null && lead.Email == null){
            lead.Mobilephone__c.addError('You need at least one contact option, a streetaddress, a phone or a mobilephone number');
        } 
    }
    
    // Using a single database query, find all the leads in the database that have the same 
    // email adress, phone number or mobilephone number as any of the leads being inserted or updated. 
    for (Lead lead : [SELECT Email FROM Lead WHERE Email IN :leadMap.KeySet()]){
        Lead newLead = leadMap.get(lead.Email);
        newLead.Email.addError('A lead with this email address already exists.');
    }
    for (Lead lead : [SELECT Phone FROM Lead WHERE Phone IN :leadMap.KeySet()]){
        Lead newLead = leadMap.get(lead.Phone);
        newLead.Phone.addError('A lead with this phone number already exists.');
    }
    for (Lead lead : [SELECT Mobilephone__c FROM Lead WHERE Mobilephone__c IN :leadMap.KeySet()]){
        Lead newLead = leadMap.get(lead.Mobilephone__c);
        newLead.Mobilephone__c.addError('A lead with this mobilephone number already exists.');
    }
}

 

testclass:

/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class TESTpreventDuplicatedLeadEntriesClass{		
	static Lead createLead(){
    	Lead lead = new Lead();        
        lead.LastName = 'Test';
        lead.Company = 'TestCompany';
        lead.Street = 'Teststrasse';
        lead.Streetnumber__c = '1';
        lead.Phone = '03412222531';
        lead.Mobilephone__c = '01777777771';
        lead.Email = 'test@gmail.com';
        return lead;
    }
    
	//Insertcontrol
	    static testMethod void shouldThrowExceptionOnInsertALeadWithADuplicateMobilePhoneNumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
		    try{
		    	insert leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Mobilephone__c = '01777777772';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnInsertALeadWithADuplicatePhoneNumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
	        insert leadA;
        	leadB.Mobilephone__c = '01777777772';
			leadB.Email = 'test2@gmail.com';
		    try{
		    	insert leadB;
	    	}
		    catch(System.DmlException e){
		    	try{
		    		leadB.Phone = '03412222532';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnInsertALeadWithADuplicateEMailadress(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
	        insert leadA;
	        leadB.Phone = '03412222532';
        	leadB.Mobilephone__c = '01777777772';
		    try{
		    	insert leadB;
	    	}
		    catch(System.DmlException e){
		    	try{
		    		leadB.Email = 'test2@gmail.com';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnInsertALeadWithoutAStreetnumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        		        
		    insert leadA;
		    leadB.Phone = '03412222532';
        	leadB.Mobilephone__c = '01777777772';
			leadB.Email = 'test2@gmail.com';
			leadB.Streetnumber__c = '';
		    try{
		    	insert leadB;		    	
	    	}
		    catch(System.DmlException e){
		    	try{
		    		leadB.Streetnumber__c = '2';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnInsertALeadWithoutAnyContactInformation(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
	        insert leadA;
	        leadB.Company = 'TestCompany';
	        leadB.Street = '';
	        leadB.Streetnumber__c = '';
	        leadB.Phone = '';
	        leadB.Mobilephone__c = '';
	        leadB.Email = '';
		    try{
		    	insert leadB;
	    	}
		    catch(System.DmlException e){
		    	try{
		    		leadB.Company = 'TestCompany';
					leadB.Street = 'advadf';
					leadB.Streetnumber__c = '2';
					leadB.Phone = '03412222532';
					leadB.Mobilephone__c = '01777777772';
					leadB.Email = 'test2@gmail.com';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e.getDmlMessage(0));
		    	}
		    }
	    }
    //Insertcontrol end
    
    //Updatecontrol
    	static testMethod void shouldThrowExceptionOnUpdateALeadWithADuplicateMobilePhoneNumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
			leadB.Mobilephone__c = '01777777772';
			insert leadB;
		    try{
		    	leadB.Mobilephone__c = '01777777771';
		    	update leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Mobilephone__c = '01777777772';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnUpdateALeadWithADuplicatePhoneNumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
			leadB.Mobilephone__c = '01777777772';
			insert leadB;
		    try{
		    	leadB.Phone = '03412222531';
		    	update leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Phone = '03412222532';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
    	static testMethod void shouldThrowExceptionOnUpdateALeadWithADuplicateEMailadress(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
			leadB.Mobilephone__c = '01777777772';
			insert leadB;
		    try{
		    	leadB.Email = 'test@gmail.com';
		    	update leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Email = 'test2@gmail.com';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }  
	    static testMethod void shouldThrowExceptionOnUpdateALeadWithoutAStreetnumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
			leadB.Mobilephone__c = '01777777772';
			leadB.Streetnumber__c = '2';
			insert leadB;
		    try{
		    	leadB.Streetnumber__c = '0';
		    	update leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Streetnumber__c = '2';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnUpdateALeadWithoutAnyContactInformation(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
			leadB.Mobilephone__c = '01777777772';
			leadB.Streetnumber__c = '2';
			insert leadB;
		    try{
		    	leadB.Company = 'TestCompany';
		        leadB.Street = '';
		        leadB.Streetnumber__c = '';
		        leadB.Phone = '';
		        leadB.Mobilephone__c = '';
		        leadB.Email = '';
		    	update leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Company = 'TestCompany2';
					leadB.Street = 'Test2street';
					leadB.Streetnumber__c = '2';
					leadB.Phone = '03412222532';
					leadB.Mobilephone__c = '01777777772';
					leadB.Email = 'test2@gmail.com';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
    //Updatecontrol end   
}

 

Hey Guys,

 

here i am again.

 

so, well, i wanted to deploy my trigger to prevent duplicates, the trigger works definetely.

 

but i cant deploy it during Code coverage from 63% (21/33)

 

there u got a picture from the red lines in my code who isnt checked.

http://www7.pic-upload.de/30.09.13/wkjkc9yifc66.png

 

 

and here is the Error from Deployment try

http://www7.pic-upload.de/30.09.13/8kxhclrs27ol.png

 

 

So my qustion is, how can i fix it that i can deploy it from sandbox in my organisation? 

 

hey guys,

 

if i try to instal any app, and i am sysadmin and have all rights to install aps and so on. So i gone all steps through, click then on install and the install button changes to this:

 

http://tinypic.com/r/3149da9/5

 

and stay at this status, i waited more then 10 minutes, but nthn happend

 

anyone know whats goin on here?

Hey guys,

 

i need to know how i can write a trigger that he will fire before i convert a lead into a company, that the trigger can check if the company is already there and perform a merge then? any ideas? 

 

 

Hey guys,

 

i'm really new to Salesforce and i already tried to use the board here, but i havent find anything what i can use.

So here is the Description of my problem: 

 

I got a listfield from what i pick an entry (industry), and based on that pick i got a sub listfield (area) to specify which service area the customer or company is specified. And i want to know, if and how it is possible to change the name of the Fielddescription (area) to another specified like marque of the car.

 

exampel : we got 2 entries in the first listfield like cardealer and painter. based on the entry whats picked from the first list should changed the Description Text like car marque or color.

 

http://s1.directupload.net/images/130905/imefpibf.png

 

Hey guys, i got a code coverage from 89%.

 

Well i want to max it to 100%, just for myself, but i dont know how to to improve the code coverage for nested if statements, can anyone give me an idea?

 

see code below 

the underlined is not covered, which i want to get covered

 

trigger : 

 

trigger preventDuplicateLeadEntriesByEmailAndPhoneAndMobilePhone on Lead (before insert, before update){
    Map<String, Lead> leadMap = new Map<String, Lead>();
    for (Lead lead : System.Trigger.new){
        // To make sure we don't treat an email address, phone or mobilephone number 
        // that isn't changing during an update as a duplicate.   
        if ((lead.Email != null) && (System.Trigger.isInsert || (lead.Email != System.Trigger.oldMap.get(lead.Id).Email))){
            if (leadMap.containsKey(lead.Email)){
                lead.Email.addError('Another lead has the same email address.');            } 
            else{
                leadMap.put(lead.Email, lead);
            }
        }  
        if ((lead.Phone != null) && (System.Trigger.isInsert || (lead.Phone != System.Trigger.oldMap.get(lead.Id).Phone))){
            if (leadMap.containsKey(lead.Phone)){
                lead.Phone.addError('Another lead has the same Phone number.');            } 
            else{
                leadMap.put(lead.Phone, lead);
            }
        }
        if ((lead.Mobilephone__c != null) && (System.Trigger.isInsert || (lead.Mobilephone__c != System.Trigger.oldMap.get(lead.Id).Mobilephone__c))){
            if (leadMap.containsKey(lead.Mobilephone__c)){
                lead.Mobilephone__c.addError('Another lead has the same Mobilephone number.');            } 
            else{
                leadMap.put(lead.Mobilephone__c, lead);
            }
        }
        
        //To make sure that the customer has entered the streetnumber
        if (lead.Streetnumber__c == null){
        	lead.Streetnumber__c.addError('Please review your streetadress and paste your streetnumber here');
        }
        
        /*
        //To make sure that the Street and streetnumber isnt äquivalent to an existing phone or mobilephone number  
        */
                
        // To make sure that the customer has entered a mobilephone or telephon number or a address to contact him later
        if (lead.LastName == null && lead.Street == null && lead.Mobilephone__c == null && lead.Phone == null && lead.Email == null){
            lead.Mobilephone__c.addError('You need at least one contact option, a streetaddress, a phone or a mobilephone number');
        } 
    }
    
    // Using a single database query, find all the leads in the database that have the same 
    // email adress, phone number or mobilephone number as any of the leads being inserted or updated. 
    for (Lead lead : [SELECT Email FROM Lead WHERE Email IN :leadMap.KeySet()]){
        Lead newLead = leadMap.get(lead.Email);
        newLead.Email.addError('A lead with this email address already exists.');
    }
    for (Lead lead : [SELECT Phone FROM Lead WHERE Phone IN :leadMap.KeySet()]){
        Lead newLead = leadMap.get(lead.Phone);
        newLead.Phone.addError('A lead with this phone number already exists.');
    }
    for (Lead lead : [SELECT Mobilephone__c FROM Lead WHERE Mobilephone__c IN :leadMap.KeySet()]){
        Lead newLead = leadMap.get(lead.Mobilephone__c);
        newLead.Mobilephone__c.addError('A lead with this mobilephone number already exists.');
    }
}

 

testclass:

/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class TESTpreventDuplicatedLeadEntriesClass{		
	static Lead createLead(){
    	Lead lead = new Lead();        
        lead.LastName = 'Test';
        lead.Company = 'TestCompany';
        lead.Street = 'Teststrasse';
        lead.Streetnumber__c = '1';
        lead.Phone = '03412222531';
        lead.Mobilephone__c = '01777777771';
        lead.Email = 'test@gmail.com';
        return lead;
    }
    
	//Insertcontrol
	    static testMethod void shouldThrowExceptionOnInsertALeadWithADuplicateMobilePhoneNumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
		    try{
		    	insert leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Mobilephone__c = '01777777772';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnInsertALeadWithADuplicatePhoneNumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
	        insert leadA;
        	leadB.Mobilephone__c = '01777777772';
			leadB.Email = 'test2@gmail.com';
		    try{
		    	insert leadB;
	    	}
		    catch(System.DmlException e){
		    	try{
		    		leadB.Phone = '03412222532';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnInsertALeadWithADuplicateEMailadress(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
	        insert leadA;
	        leadB.Phone = '03412222532';
        	leadB.Mobilephone__c = '01777777772';
		    try{
		    	insert leadB;
	    	}
		    catch(System.DmlException e){
		    	try{
		    		leadB.Email = 'test2@gmail.com';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnInsertALeadWithoutAStreetnumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        		        
		    insert leadA;
		    leadB.Phone = '03412222532';
        	leadB.Mobilephone__c = '01777777772';
			leadB.Email = 'test2@gmail.com';
			leadB.Streetnumber__c = '';
		    try{
		    	insert leadB;		    	
	    	}
		    catch(System.DmlException e){
		    	try{
		    		leadB.Streetnumber__c = '2';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnInsertALeadWithoutAnyContactInformation(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
	        insert leadA;
	        leadB.Company = 'TestCompany';
	        leadB.Street = '';
	        leadB.Streetnumber__c = '';
	        leadB.Phone = '';
	        leadB.Mobilephone__c = '';
	        leadB.Email = '';
		    try{
		    	insert leadB;
	    	}
		    catch(System.DmlException e){
		    	try{
		    		leadB.Company = 'TestCompany';
					leadB.Street = 'advadf';
					leadB.Streetnumber__c = '2';
					leadB.Phone = '03412222532';
					leadB.Mobilephone__c = '01777777772';
					leadB.Email = 'test2@gmail.com';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e.getDmlMessage(0));
		    	}
		    }
	    }
    //Insertcontrol end
    
    //Updatecontrol
    	static testMethod void shouldThrowExceptionOnUpdateALeadWithADuplicateMobilePhoneNumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
			leadB.Mobilephone__c = '01777777772';
			insert leadB;
		    try{
		    	leadB.Mobilephone__c = '01777777771';
		    	update leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Mobilephone__c = '01777777772';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnUpdateALeadWithADuplicatePhoneNumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
			leadB.Mobilephone__c = '01777777772';
			insert leadB;
		    try{
		    	leadB.Phone = '03412222531';
		    	update leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Phone = '03412222532';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
    	static testMethod void shouldThrowExceptionOnUpdateALeadWithADuplicateEMailadress(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
			leadB.Mobilephone__c = '01777777772';
			insert leadB;
		    try{
		    	leadB.Email = 'test@gmail.com';
		    	update leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Email = 'test2@gmail.com';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }  
	    static testMethod void shouldThrowExceptionOnUpdateALeadWithoutAStreetnumber(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
			leadB.Mobilephone__c = '01777777772';
			leadB.Streetnumber__c = '2';
			insert leadB;
		    try{
		    	leadB.Streetnumber__c = '0';
		    	update leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Streetnumber__c = '2';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
	    static testMethod void shouldThrowExceptionOnUpdateALeadWithoutAnyContactInformation(){	
	        Lead leadA = createLead();
	        Lead leadB = createLead();
	        
		    insert leadA;
		    leadB.Phone = '03412222532';
			leadB.Email = 'test2@gmail.com';
			leadB.Mobilephone__c = '01777777772';
			leadB.Streetnumber__c = '2';
			insert leadB;
		    try{
		    	leadB.Company = 'TestCompany';
		        leadB.Street = '';
		        leadB.Streetnumber__c = '';
		        leadB.Phone = '';
		        leadB.Mobilephone__c = '';
		        leadB.Email = '';
		    	update leadB;
	    	}
		    catch(System.DmlException e){
		    	try {
		    		leadB.Company = 'TestCompany2';
					leadB.Street = 'Test2street';
					leadB.Streetnumber__c = '2';
					leadB.Phone = '03412222532';
					leadB.Mobilephone__c = '01777777772';
					leadB.Email = 'test2@gmail.com';
		    	}
		    	catch(System.DmlException e1){
		    		System.assertEquals('Error: ', e1.getDmlMessage(0));
		    	}
		    }
	    }
    //Updatecontrol end   
}

 

Hey Guys,

 

here i am again.

 

so, well, i wanted to deploy my trigger to prevent duplicates, the trigger works definetely.

 

but i cant deploy it during Code coverage from 63% (21/33)

 

there u got a picture from the red lines in my code who isnt checked.

http://www7.pic-upload.de/30.09.13/wkjkc9yifc66.png

 

 

and here is the Error from Deployment try

http://www7.pic-upload.de/30.09.13/8kxhclrs27ol.png

 

 

So my qustion is, how can i fix it that i can deploy it from sandbox in my organisation? 

 

hey guys,

 

if i try to instal any app, and i am sysadmin and have all rights to install aps and so on. So i gone all steps through, click then on install and the install button changes to this:

 

http://tinypic.com/r/3149da9/5

 

and stay at this status, i waited more then 10 minutes, but nthn happend

 

anyone know whats goin on here?

Hey guys,

 

i need to know how i can write a trigger that he will fire before i convert a lead into a company, that the trigger can check if the company is already there and perform a merge then? any ideas? 

 

 

So we enabled communities and ChatterAnswers on our org and it has caused no end of problems.  When trying to deploy from sandbox to production and the test classes keep failing in ChatterAnswers (even though we're not deploying anything there).  I know it's because all tests have to run on deploy, but it seems the tests are problematic.

 

First there was one that gets the first user and assigns an account to it.  Since you can't assign an accuont to an inactive user, and our first user happens to be inactive, the test fails.  So I had to edit it to select the first ACTIVE user, and that test passes now.  Now I'm getting another failure with the class ChatterAnswersEscalationTriggerTest failing with errors.

 

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []", Failure Stack Trace: "Class.ChatterAnswersEscalationTriggerTest.validateQuestionEscalation: line 14, column 1"

 

Advice is welcome as to how to fix this.  This has, literaly, crippled our development because we can't push any product into where it's getting used on our internal ORG.

 

I have a trigger I would like to roll out to production, but I am getting errors with test classes from installed packages.

 

Specifically related to Chatter Answers.  I am unable to delete or inactivate chatter_answers_question_escalation_to_case_trigger.

 

Any suggestions would be helpful.

 

 

  • July 24, 2013
  • Like
  • 0

I have developer edition environment. I want to register and authenticate users visiting my site. For that I took help of Customer Portal. I did everything as told in this (http://wiki.developerforce.com/page/Authenticating_Users_on_Force.com_Sites) document. But for registering the new user it is giving me error like this

Error:

That operation is only allowed from within an active site.

 

My site is active. I took userID and change account owner role as stated in above document. But it is not working.

How to fix this error?

What else I can do to validate  users visiting the site?

  • February 08, 2013
  • Like
  • 0
Hi,
 
I have some classes deployed to my production-system and now I want to delete some of them. When I right-klick on the delete button in my Eclipse project I get a message wich I have to confirm - until there everythin works fine.
 
But after I had confirmed this delete-message I get an Error-Message:
 
"Remote delete failed with the following message. Delete will be aborted. SOmyInitConCalcTrigger_isTest: null package.xml: null"
 
So, can anyone help me out or is there another way do delete the class in the production-system, because in sf I can't find any way to delete this classes?!
 
Thanks in advance for any help
regards
Sascha