• Nick Speyer
  • NEWBIE
  • 25 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 12
    Replies
Does anyone have a suggestion as to how I can customize the LiveAgent chat window using Visualforce? I have run sample codes for the active site homepage within the force.com site then loaded this site into the "Branding Image Site" and nothing entered there seems to alter the appearance of the LiveAgent chat window. Any help would be much appreciated.

Also, I have entered a static resource png image into the deployment's "Chat Window Branding Image", however nothing seems to appear. 

Thanks,
Nick
Hello,

I am currently having trouble with process builder. I have written three processes, which all aim to update their corresponding object after specific triggers have been run. For example, one trigger calculates specific commissions to be paid to certain sales persons upon the change of their sales volume. The trigger works after clicking "edit" and "save" on the object - the process has been build to update the object after changing their sales volume, therefore eliminating the need to click "edit" and "save". I have three triggers that all work in a similar fashion and all require the same sort of process to update their data. Keep in mind these are all After Insert and After Update triggers - not sure if this plays a part in my problem.

My problem is that these process are refusing to run simultaneously. Currently, even when I have activated all three, the first process activated is the only one that does what it is supposed to. The others stay active but have no effect. When I deactivate the first process the second one begins to work, and so on. I have had the processes built into one process and have also broken them out into individual processes - neither solution has worked. Each process depends on an update within the opportunity object, for example update the commission object when stage field on the opportunity is changed to complete. This dependency on the opportunity object seems to be the only relationship that exists between the three processes.

I have been told to look into my debug logs; however I cannot seem to find a problem. They are very long so I have no posted them into this forum. Does anybody have any ideas? If needed I can send the debug logs in an email.

Thank you for your time.
Hello,

I have several opportunities, which all have a record field assigned to a specific project. The project, which they are assigned to is mapped through a look up field. My goal is to create a trigger, which sums every opportunity's CS_Capacity_Allocated__C field (this is the individual's capacity reservation) that is assigned to the same project and create a total capacity value to be mapped into a newly created CS_Reserved_Capacity__C field (this is all the individual's capacity reservations added together). One could then view the total project capacity on each opportunity.

A Roll Up Summary would be ideal for this situation; however I cannot establish a Master-Detail relationship on the opportunity with the project object, nor can I establish a Roll Up Summary on the project because the "Summarized Object" drop-down menu does not allow me to acces the opportunities option. 

This has left me, from what I believe, with the need to develop a trigger. I have authored the following code; however it has confronted me with several error messages, which I have been fixing along the way. It has just recently sent me the following error message 

Error: Compile Error: Expression cannot be assigned at line -1 column -1

I cannot seem to work this one out. The code is as follows:
 
Trigger addReservedCapacity on opportunity (before insert, before update) {

set <string> projectNames = new Set <string>( ); 
List <decimal> projectAllocations = new List <decimal>( );
decimal reservedCapacity = 0;
integer i = 0;

// instantiate the variables.


    for (opportunity opportunity: trigger.new) {
    
        If (opportunity.assigned_cs_project__c != null) {
    
            projectNames.add (opportunity.assigned_cs_project__c);}
    }

// if the opportunity has an assigned project add the name of the project to a set.


    if (projectNames.size( ) > 0 ) {
    
        map <string, decimal> mapNames = new map <string, decimal> ( );
        
        for (opportunity obj : [SELECT Id, name, assigned_cs_project__c, cs_capacity_allocated__c FROM opportunity WHERE assigned_cs_project__c IN : projectNames] ) {

            mapNames.put(obj.assigned_cs_project__c,obj.cs_capacity_allocated__c);
        }

// create a map and query the opportunity records looking for records that have matching project assignments to the created set. 
// return the found record’s id, name, project assignment and reserved capacity
// put the project assignment into the map as the key and the reserved capacity as the value.


    projectAllocations = mapNames.values();

// set the projectAllocations list to the reserved capacity values in the map.


    for(i = 0; i <= mapNames.size(); i++){

        reservedCapacity = reservedCapacity  + projectAllocations.get(i);

     }

// sum the lines of the list

    
    opportunity.cs_reserved_capacity__c = reservedCapacity;

// set the CS Reserved Capacity field in the Projects object to the calculated reserved capacity.


    }
}

If anybody could help I would really appreciate it. Regardless, thank you for your time in reading this.

All the best.
 
Hello,

I have several opportunities, which all have a record field assigned to a specific project. The project, which they are assigned to is mapped through a look up field. My goal is to create a trigger, which sums every opportunity's CS_Capacity_Allocated__C field (this is the individual's capacity reservation) that is assigned to the same project and create a total capacity value to be mapped into a newly created CS_Reserved_Capacity__C field (this is all the individual's capacity reservations added together). One could then view the total project capacity on each opportunity.

A Roll Up Summary would be ideal for this situation; however I cannot establish a Master-Detail relationship on the opportunity with the project object, nor can I establish a Roll Up Summary on the project because the "Summarized Object" drop-down menu does not allow me to acces the opportunities option. 

This has left me, from what I believe, with the need to develop a trigger. I have authored the following code; however it has confronted me with several error messages, which I have been fixing along the way. It has just recently sent me the following error message 

Error: Compile Error: Expression cannot be assigned at line -1 column -1

I cannot seem to work this one out. The code is as follows:
Trigger addReservedCapacity on opportunity (before insert, before update) {

set <string> projectNames = new Set <string>(); 
List <decimal> projectAllocations = new List <decimal>( );
decimal reservedCapacity = 0;
integer i = 0;

// instantiate the variables.

    for (opportunity opportunity: trigger.new) {
    
        If (opportunity.assigned_cs_project__c != null) {
    
            projectNames.add (opportunity.assigned_cs_project__c);}
    }

// if the opportunity has an assigned project add the name of the project to a set.

    if (projectNames.size( ) > 0 ) {
    
        map <string, decimal> mapNames = new map <string, decimal> ( );
        
        for (opportunity obj : [SELECT Id, name, assigned_cs_project__c, cs_capacity_allocated__c FROM opportunity WHERE assigned_cs_project__c IN : projectNames] ) {

            mapNames.put(obj.assigned_cs_project__c,obj.cs_capacity_allocated__c);
        }
        
// create a map and query the opportunity records looking for records that have matching project assignments to the created set. 
// return the found record’s id, name, project assignment and reserved capacity
// put the project assignment into the map as the key and the reserved capacity as the value.

    projectAllocations = mapNames.values();

// set the projectAllocations list to the reserved capacity values in the map.

    for(i = 0; i <= mapNames.size(); i++){

        reservedCapacity = reservedCapacity  + projectAllocations.get(i);

     }

// sum the lines of the list

    opportunity.cs_reserved_capacity__c = reservedCapacity;

// set the CS Reserved Capacity field in the Projects object to the calculated reserved capacity.

    }
}

If anybody could help I would really appreciate it. Regardless, thank you for your time in reading this.

All the best.



 
Hi All,

I've got a trigger i've been working on that does all the requirements I need it to. I am at the final stretch of deployment and need to write a test method that will give me adequate code coverage to deploy.

The basis of the code is very similar to a VLOOKUP function. I have a set of 700+ records which include a zip code in the name field and a specific "Load Zone" in the second field. My code keys off of an updated parcel zip code in the opportunity object as a reference and returns the proper load zone for that zip code from the list of records - again, much like a VLOOKUP. I now have to develop test methods to ensure code coverage. Is anybody willing to help?

The Trigger is as follows:

Parcel_Zip__c is the field in Opportunity being referenced in the Load_U__c object that holds the name field being searched through and returning the corresponding Load_Zone__c field's value into the Load_Zone_Utility_4__C field in the opportunity object.
 
Trigger updateLZU on Opportunity (before insert, before update) {

	set <string> ZipCodes = new Set <string>( ); 
	//creates a set labeled zip codes to hold the Parcel Zip Codes being referenced 

	for ( opportunity l : trigger.new) {
	
		If ( l.Parcel_Zip__c != null) {
	
			ZipCodes.add (l.Parcel_Zip__c);}
	}
	//loads the Parcel Zip Code field values into the ZipCodes set using a for loop that starts when the Parcel Zip Code contains a value.

	if ( ZipCodes.size( ) > 0 ) {
	
		map <string, Load_u__c> validLZU = new map <string, Load_u__c> ( );
		//creates a map labeled validLZU with a key of string data type and a value in the Load Zone & Utilites object.
		
		for (Load_u__c obj : [SELECT Id, name, Load_Zone__C 
                                                  FROM Load_u__C 
                                                  WHERE name
                                                  IN : ZipCodes] ) {
		//creates a for loop that queries the Load Zone & Utilities’ object records for the matching  zip code being stored in the ZipCodes set and returns the name and Load Zone fields.

			validLZU.put (obj.name, obj); 
			//loads the name (zip code) returned by the query into the key value of the validLZU map and loads the query as the map’s value.
		}
		
	for ( opportunity l : trigger.new) {

		if ( trigger.isInsert || trigger.oldMap.get(l.Id).ZipCode != l.Parcel_Zip__c && validLZU.containsKey (l.Parcel_Zip__c)) {
		// if the parcel zip code is inserted or if the parcel zip code is different than what it used to be and the map contains a name equal to the parcel zip code than execute:

			l.load_zone_utility_4__C = validLZU.get (l.Parcel_Zip__c).Load_Zone__C;
			//set the Load Zone & Utility field in the opportunity object to the corresponding Load Zone & utility field in the Load Zone & Utility object depending on the parcel zip code.
			
		}

		else if(trigger.oldMap.get(l.iD).Parcel_Zip__c != l.Parcel_Zip__c && !validLZU.containsKey(l.Parcel_Zip__c)) {
		// if the old parcel zip code is equal to the current parcel zip code and the map does not contain the parcel zip code execute:

			l. load_zone_utility_4__C __C = null;
			//set the Load Zone & Utility field in the opportunity object to null.
	}
}
}
}

My test class is as follows:
 
@isTest
private class leadsLZUTriggerTestClass {

Static testMethod void validateLZUL(){

lead newLead = new lead(firstName = ‘James’, lastName = ‘Sullivan’, company = ‘Walmart’, status = 'contacted', Parcel_Zip__c = '02052') ;
Load_U newLZU = new Load_U ( name = '02052', Load_zone__c= 'NEMA Eversource');

//create new Load Zone and Lead objects to be used in the test.

newLead.FirstName = 'Cole';
newLead.LastName = 'Swain';
newLead.Company = 'BlueWave';
newLead.Status = 'contacted';
newLead.Parcel_Zip__C = '02052';

//update the new lead’s field values

newLZU.name = '02052';
newLZU.Load_Zone__c = 'NEMA Eversource';

//update the new load zone’s fields values

test.startTest();
 
insert newLead;

database.leadConvert lc = new database.leadConvert();
lc.setLeadId(newLead.id);

leadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);

Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());

lc.setOpportunityName(‘James Sullivan’);

//convert the new lead into an opportunity object and set its name to ‘James Sullivan’
 
test.stopTest();
 
opportunity opQuery = [SELECT name, Load_Zone_Utility_4__c FROM opportunity WHERE name = ‘James Sullivan];

//query the opportunity object for records with the name = ‘James Sullivan’ and return name and Load Zone
 
system.assertEquals('NEMA Eversource', opQuery. Load_Zone_Utility_4__c);
 
//assert that the outcome is correct
 
}
}

I am having trouble with the conversion piece of the code. I want to convert the created lead into an opportunity, then reference this opportunity using a query. 

I receive the following error message when I run the test:

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, updateLZUL: execution of BeforeInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.updateLZUL: line 25, column 1: []

Anybody have any idea what I am doing wrong? 
Hi everybody,

I've got a trigger i've been working on that does all the requirements I need it to. I am at the final stretch of deployment and need to write a test method that will give me adequate code coverage to deploy.

The basis of the code is very similar to a VLOOKUP function. I have a set of 700+ records which include a zip code in the name field and a specific "Load Zone" in the second field. My code keys off of an updated parcel zip code in the opportunity object as a reference and returns the proper load zone for that zip code from the list of records - again, much like a VLOOKUP. I now have to develop test methods to ensure code coverage. Is anybody willing to help?

The Trigger is as follows:

Parcel_Zip__c is the field in Opportunity being referenced in the Load_U__c object that holds the name field being searched through and returning the corresponding Load_Zone__c field's value into the Load_Zone_Utility_4__C field in the opportunity object.
 
Trigger updateLZU on Opportunity (before insert, before update) {

	set <string> ZipCodes = new Set <string>( ); 
	//creates a set labeled zip codes to hold the Parcel Zip Codes being referenced 

	for ( opportunity l : trigger.new) {
	
		If ( l.Parcel_Zip__c != null) {
	
			ZipCodes.add (l.Parcel_Zip__c);}
	}
	//loads the Parcel Zip Code field values into the ZipCodes set using a for loop that starts when the Parcel Zip Code contains a value.

	if ( ZipCodes.size( ) > 0 ) {
	
		map <string, Load_u__c> validLZU = new map <string, Load_u__c> ( );
		//creates a map labeled validLZU with a key of string data type and a value in the Load Zone & Utilites object.
		
		for (Load_u__c obj : [SELECT Id, name, Load_Zone__C FROM Load_u__C WHERE name IN : ZipCodes] ) {
		//creates a for loop that queries the Load Zone & Utilities’ object records for the matching  zip code being stored in the ZipCodes set and returns the name and Load Zone fields.

			validLZU.put (obj.name, obj); 
			//loads the name (zip code) returned by the query into the key value of the validLZU map and loads the query as the map’s value.
		}
		
	for ( opportunity l : trigger.new) {

		if ( trigger.isInsert || trigger.oldMap.get(l.Id).ZipCode != l.Parcel_Zip__c && validLZU.containsKey (l.Parcel_Zip__c)) {
		// if the parcel zip code is inserted or if the parcel zip code is different than what it used to be and the map contains a name equal to the parcel zip code than execute:

			l.load_zone_utility_4__C = validLZU.get (l.Parcel_Zip__c).Load_Zone__C;
			//set the Load Zone & Utility field in the opportunity object to the corresponding Load Zone & utility field in the Load Zone & Utility object depending on the parcel zip code.
			
		}

		else if(trigger.oldMap.get(l.iD).Parcel_Zip__c != l.Parcel_Zip__c && !validLZU.containsKey(l.Parcel_Zip__c)) {
		// if the old parcel zip code is equal to the current parcel zip code and the map does not contain the parcel zip code execute:

			l. load_zone_utility_4__C __C = null;
			//set the Load Zone & Utility field in the opportunity object to null.
	}
}
}
}

My attempted test method is as follows:
 
@isTest
private class opportunityLZUTriggerTestClass {

Static testMethod void validateLZU(){

date myDate = date.newInstance(2016, 2, 17);
account myAccount = new account ();
//create myDate and myAccount variables to be inputted into the newOp opportunity.

opportunity newOp = new opportunity() ;
//create the newOp record in the opportunity object to play as a test record in the opportunity trigger.

newOp.name = ‘Newman Tower’;
newOp.account = myAccount;
newOp.type = 'New Business';
newOp.closeDate = myDate;
newOp.stageName = 'new';
newOp.parcel_zip__c = '02052';
newOp.Load_Zone_Utility_4__c = null;
//add values to the newOp record’s required fields. 
//because Load_Zone_Utility_4__c field is being auto-populated depending on the parcel zip code after the trigger, and is therfore currently blank, set to null.

test.startTest();
//start the test

insert newOp;
//insert the newly created record, newOp, into the opportunity object. 

test.stopTest();
//stop the test

Opportunity opQuery = [SELECT name, Load_Zone_Utility_4__c FROM opportunity WHERE name = ‘Newman Tower’];
//query the records in the opportunity object to return the name and Load Zone & Utility fields from the opportunity object where the name is equal to ‘Newman Tower’.
// set this query to the variable opQuery.

system.assertEquals('NEMA Eversource', opQuery.Load_Zone_Utility_4__c);
// Check that the Load Zone & Utility field in the query opQuery is equal to ‘NEMA Eversource’, which it should as the trigger’s job was to update this field based off of the zip code ‘02052’


}
}

The test is inputting the declared hypothetical data. Then the trigger is supposed to update the Load_Zone_Utility_4__C field based off of its Parcel_Zip__C of 02052. Therefore, originally the Load Zone field must be blank because it is dependent on the zip code - is null being used correctly to do this? 

If anybody can help, it would be greatly appreciated. 

Thank you.
 
Hello,

I have several opportunities, which all have a record field assigned to a specific project. The project, which they are assigned to is mapped through a look up field. My goal is to create a trigger, which sums every opportunity's CS_Capacity_Allocated__C field (this is the individual's capacity reservation) that is assigned to the same project and create a total capacity value to be mapped into a newly created CS_Reserved_Capacity__C field (this is all the individual's capacity reservations added together). One could then view the total project capacity on each opportunity.

A Roll Up Summary would be ideal for this situation; however I cannot establish a Master-Detail relationship on the opportunity with the project object, nor can I establish a Roll Up Summary on the project because the "Summarized Object" drop-down menu does not allow me to acces the opportunities option. 

This has left me, from what I believe, with the need to develop a trigger. I have authored the following code; however it has confronted me with several error messages, which I have been fixing along the way. It has just recently sent me the following error message 

Error: Compile Error: Expression cannot be assigned at line -1 column -1

I cannot seem to work this one out. The code is as follows:
 
Trigger addReservedCapacity on opportunity (before insert, before update) {

set <string> projectNames = new Set <string>( ); 
List <decimal> projectAllocations = new List <decimal>( );
decimal reservedCapacity = 0;
integer i = 0;

// instantiate the variables.


    for (opportunity opportunity: trigger.new) {
    
        If (opportunity.assigned_cs_project__c != null) {
    
            projectNames.add (opportunity.assigned_cs_project__c);}
    }

// if the opportunity has an assigned project add the name of the project to a set.


    if (projectNames.size( ) > 0 ) {
    
        map <string, decimal> mapNames = new map <string, decimal> ( );
        
        for (opportunity obj : [SELECT Id, name, assigned_cs_project__c, cs_capacity_allocated__c FROM opportunity WHERE assigned_cs_project__c IN : projectNames] ) {

            mapNames.put(obj.assigned_cs_project__c,obj.cs_capacity_allocated__c);
        }

// create a map and query the opportunity records looking for records that have matching project assignments to the created set. 
// return the found record’s id, name, project assignment and reserved capacity
// put the project assignment into the map as the key and the reserved capacity as the value.


    projectAllocations = mapNames.values();

// set the projectAllocations list to the reserved capacity values in the map.


    for(i = 0; i <= mapNames.size(); i++){

        reservedCapacity = reservedCapacity  + projectAllocations.get(i);

     }

// sum the lines of the list

    
    opportunity.cs_reserved_capacity__c = reservedCapacity;

// set the CS Reserved Capacity field in the Projects object to the calculated reserved capacity.


    }
}

If anybody could help I would really appreciate it. Regardless, thank you for your time in reading this.

All the best.
 
Hello,

I have several opportunities, which all have a record field assigned to a specific project. The project, which they are assigned to is mapped through a look up field. My goal is to create a trigger, which sums every opportunity's CS_Capacity_Allocated__C field (this is the individual's capacity reservation) that is assigned to the same project and create a total capacity value to be mapped into a newly created CS_Reserved_Capacity__C field (this is all the individual's capacity reservations added together). One could then view the total project capacity on each opportunity.

A Roll Up Summary would be ideal for this situation; however I cannot establish a Master-Detail relationship on the opportunity with the project object, nor can I establish a Roll Up Summary on the project because the "Summarized Object" drop-down menu does not allow me to acces the opportunities option. 

This has left me, from what I believe, with the need to develop a trigger. I have authored the following code; however it has confronted me with several error messages, which I have been fixing along the way. It has just recently sent me the following error message 

Error: Compile Error: Expression cannot be assigned at line -1 column -1

I cannot seem to work this one out. The code is as follows:
Trigger addReservedCapacity on opportunity (before insert, before update) {

set <string> projectNames = new Set <string>(); 
List <decimal> projectAllocations = new List <decimal>( );
decimal reservedCapacity = 0;
integer i = 0;

// instantiate the variables.

    for (opportunity opportunity: trigger.new) {
    
        If (opportunity.assigned_cs_project__c != null) {
    
            projectNames.add (opportunity.assigned_cs_project__c);}
    }

// if the opportunity has an assigned project add the name of the project to a set.

    if (projectNames.size( ) > 0 ) {
    
        map <string, decimal> mapNames = new map <string, decimal> ( );
        
        for (opportunity obj : [SELECT Id, name, assigned_cs_project__c, cs_capacity_allocated__c FROM opportunity WHERE assigned_cs_project__c IN : projectNames] ) {

            mapNames.put(obj.assigned_cs_project__c,obj.cs_capacity_allocated__c);
        }
        
// create a map and query the opportunity records looking for records that have matching project assignments to the created set. 
// return the found record’s id, name, project assignment and reserved capacity
// put the project assignment into the map as the key and the reserved capacity as the value.

    projectAllocations = mapNames.values();

// set the projectAllocations list to the reserved capacity values in the map.

    for(i = 0; i <= mapNames.size(); i++){

        reservedCapacity = reservedCapacity  + projectAllocations.get(i);

     }

// sum the lines of the list

    opportunity.cs_reserved_capacity__c = reservedCapacity;

// set the CS Reserved Capacity field in the Projects object to the calculated reserved capacity.

    }
}

If anybody could help I would really appreciate it. Regardless, thank you for your time in reading this.

All the best.



 
Hi All,

I've got a trigger i've been working on that does all the requirements I need it to. I am at the final stretch of deployment and need to write a test method that will give me adequate code coverage to deploy.

The basis of the code is very similar to a VLOOKUP function. I have a set of 700+ records which include a zip code in the name field and a specific "Load Zone" in the second field. My code keys off of an updated parcel zip code in the opportunity object as a reference and returns the proper load zone for that zip code from the list of records - again, much like a VLOOKUP. I now have to develop test methods to ensure code coverage. Is anybody willing to help?

The Trigger is as follows:

Parcel_Zip__c is the field in Opportunity being referenced in the Load_U__c object that holds the name field being searched through and returning the corresponding Load_Zone__c field's value into the Load_Zone_Utility_4__C field in the opportunity object.
 
Trigger updateLZU on Opportunity (before insert, before update) {

	set <string> ZipCodes = new Set <string>( ); 
	//creates a set labeled zip codes to hold the Parcel Zip Codes being referenced 

	for ( opportunity l : trigger.new) {
	
		If ( l.Parcel_Zip__c != null) {
	
			ZipCodes.add (l.Parcel_Zip__c);}
	}
	//loads the Parcel Zip Code field values into the ZipCodes set using a for loop that starts when the Parcel Zip Code contains a value.

	if ( ZipCodes.size( ) > 0 ) {
	
		map <string, Load_u__c> validLZU = new map <string, Load_u__c> ( );
		//creates a map labeled validLZU with a key of string data type and a value in the Load Zone & Utilites object.
		
		for (Load_u__c obj : [SELECT Id, name, Load_Zone__C 
                                                  FROM Load_u__C 
                                                  WHERE name
                                                  IN : ZipCodes] ) {
		//creates a for loop that queries the Load Zone & Utilities’ object records for the matching  zip code being stored in the ZipCodes set and returns the name and Load Zone fields.

			validLZU.put (obj.name, obj); 
			//loads the name (zip code) returned by the query into the key value of the validLZU map and loads the query as the map’s value.
		}
		
	for ( opportunity l : trigger.new) {

		if ( trigger.isInsert || trigger.oldMap.get(l.Id).ZipCode != l.Parcel_Zip__c && validLZU.containsKey (l.Parcel_Zip__c)) {
		// if the parcel zip code is inserted or if the parcel zip code is different than what it used to be and the map contains a name equal to the parcel zip code than execute:

			l.load_zone_utility_4__C = validLZU.get (l.Parcel_Zip__c).Load_Zone__C;
			//set the Load Zone & Utility field in the opportunity object to the corresponding Load Zone & utility field in the Load Zone & Utility object depending on the parcel zip code.
			
		}

		else if(trigger.oldMap.get(l.iD).Parcel_Zip__c != l.Parcel_Zip__c && !validLZU.containsKey(l.Parcel_Zip__c)) {
		// if the old parcel zip code is equal to the current parcel zip code and the map does not contain the parcel zip code execute:

			l. load_zone_utility_4__C __C = null;
			//set the Load Zone & Utility field in the opportunity object to null.
	}
}
}
}

My test class is as follows:
 
@isTest
private class leadsLZUTriggerTestClass {

Static testMethod void validateLZUL(){

lead newLead = new lead(firstName = ‘James’, lastName = ‘Sullivan’, company = ‘Walmart’, status = 'contacted', Parcel_Zip__c = '02052') ;
Load_U newLZU = new Load_U ( name = '02052', Load_zone__c= 'NEMA Eversource');

//create new Load Zone and Lead objects to be used in the test.

newLead.FirstName = 'Cole';
newLead.LastName = 'Swain';
newLead.Company = 'BlueWave';
newLead.Status = 'contacted';
newLead.Parcel_Zip__C = '02052';

//update the new lead’s field values

newLZU.name = '02052';
newLZU.Load_Zone__c = 'NEMA Eversource';

//update the new load zone’s fields values

test.startTest();
 
insert newLead;

database.leadConvert lc = new database.leadConvert();
lc.setLeadId(newLead.id);

leadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);

Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());

lc.setOpportunityName(‘James Sullivan’);

//convert the new lead into an opportunity object and set its name to ‘James Sullivan’
 
test.stopTest();
 
opportunity opQuery = [SELECT name, Load_Zone_Utility_4__c FROM opportunity WHERE name = ‘James Sullivan];

//query the opportunity object for records with the name = ‘James Sullivan’ and return name and Load Zone
 
system.assertEquals('NEMA Eversource', opQuery. Load_Zone_Utility_4__c);
 
//assert that the outcome is correct
 
}
}

I am having trouble with the conversion piece of the code. I want to convert the created lead into an opportunity, then reference this opportunity using a query. 

I receive the following error message when I run the test:

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, updateLZUL: execution of BeforeInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.updateLZUL: line 25, column 1: []

Anybody have any idea what I am doing wrong? 
Hi everybody,

I've got a trigger i've been working on that does all the requirements I need it to. I am at the final stretch of deployment and need to write a test method that will give me adequate code coverage to deploy.

The basis of the code is very similar to a VLOOKUP function. I have a set of 700+ records which include a zip code in the name field and a specific "Load Zone" in the second field. My code keys off of an updated parcel zip code in the opportunity object as a reference and returns the proper load zone for that zip code from the list of records - again, much like a VLOOKUP. I now have to develop test methods to ensure code coverage. Is anybody willing to help?

The Trigger is as follows:

Parcel_Zip__c is the field in Opportunity being referenced in the Load_U__c object that holds the name field being searched through and returning the corresponding Load_Zone__c field's value into the Load_Zone_Utility_4__C field in the opportunity object.
 
Trigger updateLZU on Opportunity (before insert, before update) {

	set <string> ZipCodes = new Set <string>( ); 
	//creates a set labeled zip codes to hold the Parcel Zip Codes being referenced 

	for ( opportunity l : trigger.new) {
	
		If ( l.Parcel_Zip__c != null) {
	
			ZipCodes.add (l.Parcel_Zip__c);}
	}
	//loads the Parcel Zip Code field values into the ZipCodes set using a for loop that starts when the Parcel Zip Code contains a value.

	if ( ZipCodes.size( ) > 0 ) {
	
		map <string, Load_u__c> validLZU = new map <string, Load_u__c> ( );
		//creates a map labeled validLZU with a key of string data type and a value in the Load Zone & Utilites object.
		
		for (Load_u__c obj : [SELECT Id, name, Load_Zone__C FROM Load_u__C WHERE name IN : ZipCodes] ) {
		//creates a for loop that queries the Load Zone & Utilities’ object records for the matching  zip code being stored in the ZipCodes set and returns the name and Load Zone fields.

			validLZU.put (obj.name, obj); 
			//loads the name (zip code) returned by the query into the key value of the validLZU map and loads the query as the map’s value.
		}
		
	for ( opportunity l : trigger.new) {

		if ( trigger.isInsert || trigger.oldMap.get(l.Id).ZipCode != l.Parcel_Zip__c && validLZU.containsKey (l.Parcel_Zip__c)) {
		// if the parcel zip code is inserted or if the parcel zip code is different than what it used to be and the map contains a name equal to the parcel zip code than execute:

			l.load_zone_utility_4__C = validLZU.get (l.Parcel_Zip__c).Load_Zone__C;
			//set the Load Zone & Utility field in the opportunity object to the corresponding Load Zone & utility field in the Load Zone & Utility object depending on the parcel zip code.
			
		}

		else if(trigger.oldMap.get(l.iD).Parcel_Zip__c != l.Parcel_Zip__c && !validLZU.containsKey(l.Parcel_Zip__c)) {
		// if the old parcel zip code is equal to the current parcel zip code and the map does not contain the parcel zip code execute:

			l. load_zone_utility_4__C __C = null;
			//set the Load Zone & Utility field in the opportunity object to null.
	}
}
}
}

My attempted test method is as follows:
 
@isTest
private class opportunityLZUTriggerTestClass {

Static testMethod void validateLZU(){

date myDate = date.newInstance(2016, 2, 17);
account myAccount = new account ();
//create myDate and myAccount variables to be inputted into the newOp opportunity.

opportunity newOp = new opportunity() ;
//create the newOp record in the opportunity object to play as a test record in the opportunity trigger.

newOp.name = ‘Newman Tower’;
newOp.account = myAccount;
newOp.type = 'New Business';
newOp.closeDate = myDate;
newOp.stageName = 'new';
newOp.parcel_zip__c = '02052';
newOp.Load_Zone_Utility_4__c = null;
//add values to the newOp record’s required fields. 
//because Load_Zone_Utility_4__c field is being auto-populated depending on the parcel zip code after the trigger, and is therfore currently blank, set to null.

test.startTest();
//start the test

insert newOp;
//insert the newly created record, newOp, into the opportunity object. 

test.stopTest();
//stop the test

Opportunity opQuery = [SELECT name, Load_Zone_Utility_4__c FROM opportunity WHERE name = ‘Newman Tower’];
//query the records in the opportunity object to return the name and Load Zone & Utility fields from the opportunity object where the name is equal to ‘Newman Tower’.
// set this query to the variable opQuery.

system.assertEquals('NEMA Eversource', opQuery.Load_Zone_Utility_4__c);
// Check that the Load Zone & Utility field in the query opQuery is equal to ‘NEMA Eversource’, which it should as the trigger’s job was to update this field based off of the zip code ‘02052’


}
}

The test is inputting the declared hypothetical data. Then the trigger is supposed to update the Load_Zone_Utility_4__C field based off of its Parcel_Zip__C of 02052. Therefore, originally the Load Zone field must be blank because it is dependent on the zip code - is null being used correctly to do this? 

If anybody can help, it would be greatly appreciated. 

Thank you.