+ Start a Discussion
Forrest MulduneForrest Muldune 

Apex Trigger Cross Object

All,
 
I am requesting for assistance with a cross object trigger that I have been struggling to create. This is my first attempt in creating a Cross object trigger and I would appreciate any assistance.
 
Below are the names of the objects and fields.
 
In the Judgment_Event__c I have the following fields below.
 
Action_Type__c                    (picklist)
 
Recording_Location__c          (picklist)
 
Expiration_Date__c                (date)
 
Recording_Date__c                 (date)
 
Recording_Office_State__c   (Picklist)
 
 
Below are fields I have in the Judgment_Exp_Matrix__c object.
 
Years__c       (Number)
State1__c      Lookup(State)
 
 
MY REQUEST BELOW
 
In my trigger within the Judgment_Event__c ,   when a user selects Action_Type__c  = = ‘Recording’
And  Recording_Location__c   = = ‘County’
And  Recording_Office_State__c ==’a state that user chose  from a picklist’ (example if someone selects California)
 
AND
 
In Judgment_Exp_Matrix__c when a user selects a number in the Years__c and a state within the State1__c (example: this has to be the same state in the Recording_Office_State__c in Judgment_Event__c  ). I would like the number in  Years__c to add with the date in Recording_Date__c in Judgment_Event__c , and the final calculation will be automatically populate in the Expiration_Date__c.  For example: if the date in the Recording_Date__c is 1/01/2012 and a user selects the number 2 in the Years__c field, 1/01/2014 will be automatically populated in the Expiration_Date__c .
 
Note: Just a reminder, in the Judgment_Event__c object, the State in the Recording_Office_State__c has to be the same state in the  State1__c in Judgment_Exp_Matrix__c . If the state values are not the same in both fields, then the trigger should not initiate.
 
Below is the only coding I have currently which is not much.
 
trigger NewYear on Judgment_Event__c (before insert,before update) {
    for(Judgment_Event__c JE: Trigger.new){
        if(je.Action_Type__c == 'Recording' && je.Recording_Location__c == 'County') {
    }
}

Regards,
Best Answer chosen by Forrest Muldune
Balaji Chowdary GarapatiBalaji Chowdary Garapati
can you try below code and send back the debug log once again, i dont see any issue but just to make sure
 
trigger NewYear on Judgment_Event__c (before insert,before update) {
/* 
Since we can not have the correct value of formula fields in before triggers, we need to fire a query to fetch the state information and the record it belongs to.
*/
    Set<String> States_Set=new Set<String>();//This is to collect all the states from the records on which the trigger fired.
	Map<Id,String>JEStateMap=new Map<Id,String>();//This is to collect the id of JE record and the state it needs to be used
	Map<String,Integer>CountyStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State in County record
	Map<String,Integer>OtherStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State if other state is selected
	Map<String,Integer>SecretaryStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State if secretary state is selected
	Map<Id,County__c>CountyInfoMap=new Map<Id,County__c>();//To collect all the information related to county
	Set<Id>CountyIds=new Set<Id>();
	system.debug('JE Information ***'+Trigger.new);
    for(Judgment_Event__c JE: Trigger.new){
        if(je.Action_Type__c == 'Recording' ) {
			 if(JE.Recording_Location__c=='County'){
			     if(JE.County__c!=Null)
				 CountyIds.add(JE.County__c);
			     
			 }
	         if(JE.Recording_Location__c=='Other State Office' || JE.Recording_Location__c=='Secretary of State'){
			    if(JE.Recording_Office_State__c!=Null)
				States_Set.add(JE.Recording_Office_State__c);
			 
			 }
	     }	
	}// By End of this for loop, we will have the county id information, states from Recording_Office_State__c based on conditions.
	system.debug('*** States_Set, CountyIds'+States_Set+'**'+CountyIds);
	//Time to query county and get the required state information and add it to our state list
	for(County__c countyRecord:[select id,state__r.Name From county__c where id iN :CountyIds]){
	  CountyInfoMap.put(countyRecord.id,countyRecord);
	  States_Set.add(countyRecord.state__r.Name);
	}
	//Now we have all the state information based on conditions, query the Judgment_Exp_Matrix__c and get corresponding year information.
	
	system.debug('*** States_Set, CountyInfoMap'+States_Set+'**'+CountyInfoMap);
	for(Judgment_Exp_Matrix__c JEM:[select id,Years__c,Action_Type__c,
											Recording_Location__c,State1__c,State1__r.Name,
											Recording_Location__c											
											from Judgment_Exp_Matrix__c where State1__r.Name IN :States_Set]){
	    if(JEM.Action_Type__c == 'Recording'){
			IF(JEM.Recording_Location__c=='County'  ) {
				if(JEM.Years__c!=Null)
			   CountyStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
			If(JEM.Recording_Location__c == 'Other State Office' ) {
				if(JEM.Years__c!=Null)
				OtherStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
			If(JEM.Recording_Location__c == 'Secretary of State' ) {
				if(JEM.Years__c!=Null)
				SecretaryStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
		
		}
	}// By end of this loop we will have all the information grouped on our conditions, its time to add the years to the Recording_Date__c 
	
	system.debug('Maps Coming as'+'**+CountyStateYearMap+'***'+OtherStateYearMap+'***'+SecretaryStateYearMap);
	
	 for(Judgment_Event__c JE: Trigger.new){
        if(je.Action_Type__c == 'Recording' ) {
			 if(JE.Recording_Location__c=='County' && JE.County__c!=Null && JE.Recording_Date__c!=Null){
					if(CountyStateYearMap.keyset().contains(CountyInfoMap.get(JE.County__c).state__r.Name))
					JE.Expiration_Date__c=JE.Recording_Date__c.addYears(CountyStateYearMap.get(CountyInfoMap.get(JE.County__c).state__r.Name));
			 }
	         if(JE.Recording_Location__c=='Other State Office' && JE.Recording_Office_State__c!=Null && JE.Recording_Date__c!=Null){
				if(OtherStateYearMap.keyset().contains(JE.Recording_Office_State__c))
			    JE.Expiration_Date__c=JE.Recording_Date__c.addYears(OtherStateYearMap.get(JE.Recording_Office_State__c));
			 
			 }
			 if(JE.Recording_Location__c=='Secretary of State'&& JE.Recording_Office_State__c!=Null && JE.Recording_Date__c!=Null ){
				if(SecretaryStateYearMap.keyset().contains(JE.Recording_Office_State__c))
			    JE.Expiration_Date__c=JE.Recording_Date__c.addYears(SecretaryStateYearMap.get(JE.Recording_Office_State__c));
			 
			 }
	     }	

system.debug('JE Final date for id **'+JE.Id+'***'+JE.Expiration_Date__c);
	}// By end of this loop we will have the expiration date populated based on conditions.
	
	system.debug('JE Final INFO ****'+trigger.new);
	
	
}

 

All Answers

Balaji Chowdary GarapatiBalaji Chowdary Garapati
Try the below code, comments are in the code itsself:
 
trigger NewYear on Judgment_Event__c (before insert,before update) {

    Set<String> States_Set=new Set<String>();//This is to collect all the states from the records on which the trigger fired.
    for(Judgment_Event__c JE: Trigger.new){
        if(je.Action_Type__c == 'Recording' && je.Recording_Location__c == 'County') {
		if(je.Recording_Office_State__c  !=Null)
		  States_Set.add(JE.Recording_Office_State__c);
		}
	}//By end of this look we have all the state set prepared.
	//Its time to query Judgment_Exp_Matrix__c to see the years set and preapare a Map which contains the State and corresponding years information
	Map<String,Integer> StateYear_Map=new Map<string,Integer>();
	// Assuming name is api name of field that has State names in State__c object,if not change it accordingly
	for(Judgment_Exp_Matrix__c JEM:[select id, Years__c,State1__r.Name
										From Judgment_Exp_Matrix__c 
										where State1__r.Name IN :States_Set and Years__c !=Null]){
		StateYear_Map.put(JEM.State1__r.Name,JEM.Years__c);
	}
	
	//Now update expiration dates of JE based on the information from stateyear_map
	for(Judgment_Event__c JE: Trigger.new){
	 // Verify your conditions
        if(je.Action_Type__c == 'Recording' && je.Recording_Location__c == 'County') {
			
			// verify if the state selected has any years set in Judgment_Exp_Matrix__c object
			if(JE.Recording_Office_State__c!=Null && JE.Recording_Date__c !=Null && StateYear_Map.keyset().contains(JE.Recording_Office_State__c)){
			     JE.Expiration_Date__c=JE.Recording_Date__c.addYears(StateYear_Map.get(JE.Recording_Office_State__c));
			}
		}
	}// By endof this loop you will have your expiration dates set based on the state selected and information in Judgment_Exp_Matrix__c Object.
	
}

Hope it helps:

Thanks,
Balaji
Forrest MulduneForrest Muldune

Balaji,

First and foremost I must say thank you so much for the coding. I need to learn more advance triggers in the future and I need to learn from this. 

I received an error (view below) on this trigger. do you know what is causing it?

User-added image

I will wait for your reply.

Forrest

 
Balaji Chowdary GarapatiBalaji Chowdary Garapati
Got the issue,

Please replace the statement
 StateYear_Map.put(JEM.State1__r.Name,JEM.Years__c);
which is att line number 16 with:
 StateYear_Map.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));

The problem is the types of the map and the value we are trying to add werent matching, so we need to convert the type before we add, so modified the statement.

Hope it fixes it!

Thanks,
balaji
Forrest MulduneForrest Muldune
Balaji,

In the Judgment_Event__c object I have a field below 

County__c  data Type Lookup(County)  In the County__c that contains another lookup field name State__c Lookup(State). the State__c in County object is connected to a State__c object.

I was thinking instead of adding the Recording_Office_State__c   (Picklist) from the Judgment_Event__c, in the trigger could we add the County__c Lookup(County) field in Judgment_Event__c  instead?

The trigger will determine if the State__c Lookup(State) within the County__c object  is the same state as the state1__c Lookup(State)  in Judgment_Exp_Matrix__c.

I apologize I did not think of this earlier. I tried to make the changes myself but I could not get it to work.

Thank you once again.
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@Forrest Muldune:

 I have a question for you,

You are saying that In Judgement Event you have:
1)A look up to an other object called county which inturn has a lookup to State object. 
2)A Field called Recording_Office_State__c which has state information.

Which of these two has valid state information, in other words is there is a possibility to have two different states one tied to county object and other to an other field?  If those both the fields refers to same state, why an input field instead of a formula field? It looks like quite confusing data model.

Please provide the answer to above question, which drives the trigger code! (based on which value should the expiration date be added?)

Thanks,
Balaji
Forrest MulduneForrest Muldune
Balaji,
 
Below are the answers to your question
 
You are saying that In Judgement Event you have:You are saying that In Judgement Event you have:
 
1)A look up to another object called county which inturn has a lookup to State object. Yes.
2)A Field called Recording_Office_State__c which has state information. Yes
 

I am aware having 2 state fields is confusing, but the reason why I have the picklist field Recording_Office_State__c containing the names of the States is because it is part of a field dependencies and from the best of my knowledge, a field must be a picklist field in order to create a field dependencies so therefore, I am unable to create a field dependencies on a lookup field. Am I correct on this?  This is why I have 2 separate fields with states. If there is a more practical solution to this issue I would appreciate your feedback.
 
After reading your last response, I met up with my colleagues and we made some updates to our requirements. Before I explain the updated requirements, below is a more descriptive look at the custom objects.

In the Judgment_Event__c object I have the following fields below.
 
Action_Type__c   (picklist) containing values below
 
  • Domestication
  • Federal Registration
  • Recording

Recording_Location__c (picklist)  containing values below
  • County
  • Other State Office
  • Secretary of State



Expiration_Date__c  (date)
 
Recording_Date__c   (date)
 
Recording_Office_State__c  (Picklist) contains all States
 
State__c Formula (Text) – contains formula “County__r.State__r.Name”  - New field
 
County__c    Lookup(County)
 
Note: In the County__c that contains another lookup field name State__c Lookup(State). the State__c in County object is connected to a State__c object.


In the Judgment_Exp_Matrix__c object I have the following fields below.
 
Years__c       (Number)
 
State1__c      Lookup(State)

Action_Type__c   (picklist) containing values below
  • Domestication
  • Federal Registration
  • Recording
Recording_Location__c (picklist)  containing values below
  • County
  • Other State Office
  • Secretary of State
Below is my updated requirements. I have wrote the requirements in Actions 1, 2, and 3.

ACTION 1:
 
 In the Judgment_Event__c object, when a user selects “Recording” in Action_Type__c   and “County” in Recording_Location__c , and a county value in County__c
 
Note: the state value in the State__c field in the County__c object is automatically populated in the State__c field (formula: County__r.State__r.Name)  in the Judgment_Event__c object. – thanks for your advice.
 
AND
 
Within the Judgment_Exp_Matrix__c object, when a user selects the values below
  • “Recording” in
  • “County” in Recording_Location__c
  • number in the Years__c
  • State value within the State1__c (example: this is the same state in the State__c formula(text) field in the Judgment_Event__c object ).

I would like the number in Years__c to add with the date in Recording_Date__c in Judgment_Event__c , and the final calculation will be automatically populate in the Expiration_Date__c.  For example: if the date in the Recording_Date__c is 1/01/2012 and a user selects the number 2 in the Years__c field, 1/01/2014 will be automatically populated in the Expiration_Date__c

Note: Just a reminder, in the Judgment_Event__c object, the State value in the State__c formula(text) field has to be the same state in the  State1__c in Judgment_Exp_Matrix__c . Also the value “Recording” needs to be the same in the Action_Type__c  fields in both the Judgment_Event__c and the Judgment_Exp_Matrix__c objects. Also the value “County” needs to be the same in the Recording_Location__c fields in both the Judgment_Event__c and the Judgment_Exp_Matrix__c objects.     If criteria is not met, then the trigger should not initiate.

ACTION 2:
 
In the Judgment_Event__c object, when a user selects “Recording” in Action_Type__c   and “Other State Office” in Recording_Location__c , and a state in Recording_Office_State__c.
 
AND
 
Within the Judgment_Exp_Matrix__c object, when a user select the values below
  • “Recording” in
  • “Other State Office” in Recording_Location__c
  • number in the Years__c
  • State within the State1__c (example: this is the same state in the Recording_Office_State__c field in the Judgment_Event__c object ).
 I would like the number in Years__c to add with the date in Recording_Date__c in Judgment_Event__c , and the final calculation will be automatically populate in the Expiration_Date__c.  For example: if the date in the Recording_Date__c is 1/01/2012 and a user selects the number 2 in the Years__c field, 1/01/2014 will be automatically populated in the Expiration_Date__c
 
Note: Just a reminder, in the Judgment_Event__c object, the State in the Recording_Office_State__c field has to be the same state in the  State1__c in Judgment_Exp_Matrix__c . Also the value “Recording” needs to be the same in the Action_Type__c  fields in the Judgment_Event__c and the Judgment_Exp_Matrix__c objects. Also the value “Other State Office” needs to be the same in the Recording_Location__c fields in both the Judgment_Event__c and the Judgment_Exp_Matrix__c objects.   If criteria is not met, then the trigger should not initiate.
 
 
ACTION 3:
 
In the Judgment_Event__c object, when a user selects “Recording” in Action_Type__c   and “Secretary of State” in Recording_Location__c , and a state in Recording_Office_State__c.
 
AND
 
Within the Judgment_Exp_Matrix__c object, when a user select the values below
  • “Recording” in
  • “Secretary of State” in Recording_Location__c
  • number in the Years__c
  • State within the State1__c (example: this is the same state in the Recording_Office_State__c field in the Judgment_Event__c object ).
I would like the number in Years__c to add with the date in Recording_Date__c in Judgment_Event__c , and the final calculation will be automatically populate in the Expiration_Date__c.  For example: if the date in the Recording_Date__c is 1/01/2012 and a user selects the number 2 in the Years__c field, 1/01/2014 will be automatically populated in the Expiration_Date__c
 
Note: Just a reminder, in the Judgment_Event__c object, the State in the Recording_Office_State__c field has to be the same state in the  State1__c in Judgment_Exp_Matrix__c . Also the value “Recording” needs to be the same in the Action_Type__c  fields in the Judgment_Event__c and the Judgment_Exp_Matrix__c objects. Also the value “Secretary of State” needs to be the same in the Recording_Location__c fields in both the Judgment_Event__c and the Judgment_Exp_Matrix__c objects.   If criteria is not met, then the trigger should not initiate.
 
 
Can Action 1, 2, and 3 be combined into one trigger?  This is a lot of requirements and it this takes too much of your time, I will understand.  

Regards,

Forrest

 
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@Forrest Muldune

Please try the below version and see if it works!
 
trigger NewYear on Judgment_Event__c (before insert,before update) {
/* 
Since we can not have the correct value of formula fields in before triggers, we need to fire a query to fetch the state information and the record it belongs to.
*/
    Set<String> States_Set=new Set<String>();//This is to collect all the states from the records on which the trigger fired.
	Map<Id,String>JEStateMap=new Map<Id,String>();//This is to collect the id of JE record and the state it needs to be used
	Map<String,Integer>CountyStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State in County record
	Map<String,Integer>OtherStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State if other state is selected
	Map<String,Integer>SecretaryStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State if secretary state is selected
	Map<Id,County__c>CountyInfoMap=new Map<Id,County__c>();//To collect all the information related to county
	
    for(Judgment_Event__c JE: Trigger.new){
        if(je.Action_Type__c == 'Recording' ) {
			 if(JE.Recording_Location__c=='County'){
			     if(JE.County__c!=Null)
			     CountyInfoMap.put(JE.County__c,new county__c());
			 }
	         if(JE.Recording_Location__c=='Other State Office' || JE.Recording_Location__c=='Secretary of State'){
			    if(JE.Recording_Office_State__c!=Null)
				States_Set.add(JE.Recording_Office_State__c);
			 
			 }
	     }	
	}// By End of this for loop, we will have the county id information, states from Recording_Office_State__c based on conditions.
	//Time to query county and get the required state information and add it to our state list
	for(County__c countyRecord:[select id,state__r.Name From county__c where id iN :CountyInfoMap.keyset()]){
	  CountyInfoMap.put(countyRecord.id,countyRecord);
	  States_Set.add(countyRecord.state__r.Name);
	}
	//Now we have all the state information based on conditions, query the Judgment_Exp_Matrix__c and get corresponding year information.
	
	
	for(Judgment_Exp_Matrix__c JEM:[select id,Years__c,Action_Type__c,
											Recording_Location__c,Years__c,State1__c,State1__r.Name,
											Recording_Location__c											
											from Judgment_Exp_Matrix__c where State1__r.Name IN States_Set]){
	    if(JEM.Action_Type__c == 'Recording'){
			IF(JEM.Recording_Location__c=='County'  ) {
				if(JEM.Years__c!=Null)
			   CountyStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
			If(JEM.Recording_Location__c == 'Other State Office' ) {
				if(JEM.Years__c!=Null)
				OtherStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
			If(JEM.Recording_Location__c == 'Secretary of State' ) {
				if(JEM.Years__c!=Null)
				SecretaryStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
		
		}
	}// By end of this loop we will have all the information grouped on our conditions, its time to add the years to the Recording_Date__c 
	
	
	 for(Judgment_Event__c JE: Trigger.new){
        if(je.Action_Type__c == 'Recording' ) {
			 if(JE.Recording_Location__c=='County' && JE.County__c!=Null && JE.Recording_Date__c!=Null){
					if(CountyStateYearMap.keyset().contains(CountyInfoMap.get(JE.County__c).state__r.Name))
					JE.Expiration_Date__c=JE.Recording_Date__c.addYears(CountyStateYearMap.get(CountyInfoMap.get(JE.County__c).state__r.Name));
			 }
	         if(JE.Recording_Location__c=='Other State Office' && JE.Recording_Office_State__c!=Null && JE.Recording_Date__c!=Null){
				if(OtherStateYearMap.keyset().contains(JE.Recording_Office_State__c))
			    JE.Expiration_Date__c=JE.Recording_Date__c.addYears(OtherStateYearMap.get(JE.Recording_Office_State__c));
			 
			 }
			 if(JE.Recording_Location__c=='Secretary of State'&& JE.Recording_Office_State__c!=Null && JE.Recording_Date__c!=Null ){
				if(SecretaryStateYearMap.keyset().contains(JE.Recording_Office_State__c))
			    JE.Expiration_Date__c=JE.Recording_Date__c.addYears(SecretaryStateYearMap.get(JE.Recording_Office_State__c));
			 
			 }
	     }	
	}// By end of this loop we will have the expiration date populated based on conditions.
	
	
	
	
}


For the question you have about the dependency, you are correct, to have the dependency set, we need it as a picklist in case of standard page layout, we can also do this by visualforce page, which can have all the logic at the controller instead of at the trigger.


Hope it helps:

Please select it as best answer if it satisfy your req.

Thanks,
Balaji
Forrest MulduneForrest Muldune
Balaji,

This is amazing how you developed this coding., very amazing!

unfortunately I received a Compile Error below.

User-added image

Do I need to place a colon somewhere in this code?
 
Forrest MulduneForrest Muldune
Balaji,

I think I found the problem. I wrote The State1__c field in Judgment_Exp_Matrix__c  incorrectly. The State1__c field is a lookup field Lookup(State). Not what I wrote below.

State within the State1__c (example: this is the same state in the Recording_Office_State__c field in the Judgment_Event__c object ).

below is the correct description

State1__c Lookup(State). 

the State__c in Judgment_Event__c object is a Formula (Text) field.

so sorry for the mistake in writing.

 
Balaji Chowdary GarapatiBalaji Chowdary Garapati
Yupp! I missed a colon.  just put ":" before States_set in line 36
Forrest MulduneForrest Muldune
Ok, I will place the colon.
Forrest MulduneForrest Muldune
I received one more error below.

User-added image

In this code , do I need to delete Years__c in line 33?
Balaji Chowdary GarapatiBalaji Chowdary Garapati
Yes you can remove one, i added same field twice
Forrest MulduneForrest Muldune
I received another error below.
"Error: Compile Error: Incompatible value type Decimal for MAP<String,Integer> at line 40 column 16

User-added image
Balaji Chowdary GarapatiBalaji Chowdary Garapati
Oh i think you copied that code  too early :) actually i changed that comment after posting it in few seconds please copy now the below code! 
trigger NewYear on Judgment_Event__c (before insert,before update) {
/* 
Since we can not have the correct value of formula fields in before triggers, we need to fire a query to fetch the state information and the record it belongs to.
*/
    Set<String> States_Set=new Set<String>();//This is to collect all the states from the records on which the trigger fired.
	Map<Id,String>JEStateMap=new Map<Id,String>();//This is to collect the id of JE record and the state it needs to be used
	Map<String,Integer>CountyStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State in County record
	Map<String,Integer>OtherStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State if other state is selected
	Map<String,Integer>SecretaryStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State if secretary state is selected
	Map<Id,County__c>CountyInfoMap=new Map<Id,County__c>();//To collect all the information related to county
	
    for(Judgment_Event__c JE: Trigger.new){
        if(je.Action_Type__c == 'Recording' ) {
			 if(JE.Recording_Location__c=='County'){
			     if(JE.County__c!=Null)
			     CountyInfoMap.put(JE.County__c,new county__c());
			 }
	         if(JE.Recording_Location__c=='Other State Office' || JE.Recording_Location__c=='Secretary of State'){
			    if(JE.Recording_Office_State__c!=Null)
				States_Set.add(JE.Recording_Office_State__c);
			 
			 }
	     }	
	}// By End of this for loop, we will have the county id information, states from Recording_Office_State__c based on conditions.
	//Time to query county and get the required state information and add it to our state list
	for(County__c countyRecord:[select id,state__r.Name From county__c where id iN :CountyInfoMap.keyset()]){
	  CountyInfoMap.put(countyRecord.id,countyRecord);
	  States_Set.add(countyRecord.state__r.Name);
	}
	//Now we have all the state information based on conditions, query the Judgment_Exp_Matrix__c and get corresponding year information.
	
	
	for(Judgment_Exp_Matrix__c JEM:[select id,Years__c,Action_Type__c,
											Recording_Location__c,State1__c,State1__r.Name,
											Recording_Location__c											
											from Judgment_Exp_Matrix__c where State1__r.Name IN :States_Set]){
	    if(JEM.Action_Type__c == 'Recording'){
			IF(JEM.Recording_Location__c=='County'  ) {
				if(JEM.Years__c!=Null)
			   CountyStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
			If(JEM.Recording_Location__c == 'Other State Office' ) {
				if(JEM.Years__c!=Null)
				OtherStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
			If(JEM.Recording_Location__c == 'Secretary of State' ) {
				if(JEM.Years__c!=Null)
				SecretaryStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
		
		}
	}// By end of this loop we will have all the information grouped on our conditions, its time to add the years to the Recording_Date__c 
	
	
	 for(Judgment_Event__c JE: Trigger.new){
        if(je.Action_Type__c == 'Recording' ) {
			 if(JE.Recording_Location__c=='County' && JE.County__c!=Null && JE.Recording_Date__c!=Null){
					if(CountyStateYearMap.keyset().contains(CountyInfoMap.get(JE.County__c).state__r.Name))
					JE.Expiration_Date__c=JE.Recording_Date__c.addYears(CountyStateYearMap.get(CountyInfoMap.get(JE.County__c).state__r.Name));
			 }
	         if(JE.Recording_Location__c=='Other State Office' && JE.Recording_Office_State__c!=Null && JE.Recording_Date__c!=Null){
				if(OtherStateYearMap.keyset().contains(JE.Recording_Office_State__c))
			    JE.Expiration_Date__c=JE.Recording_Date__c.addYears(OtherStateYearMap.get(JE.Recording_Office_State__c));
			 
			 }
			 if(JE.Recording_Location__c=='Secretary of State'&& JE.Recording_Office_State__c!=Null && JE.Recording_Date__c!=Null ){
				if(SecretaryStateYearMap.keyset().contains(JE.Recording_Office_State__c))
			    JE.Expiration_Date__c=JE.Recording_Date__c.addYears(SecretaryStateYearMap.get(JE.Recording_Office_State__c));
			 
			 }
	     }	
	}// By end of this loop we will have the expiration date populated based on conditions.
	
	
	
	
}
Forrest MulduneForrest Muldune
For some reason the coding in Action 1 is not working properly. View Action 1 below.


ACTION 1:
 
 In the Judgment_Event__c object, when a user selects “Recording” in Action_Type__c   and “County” in Recording_Location__c , and a county value in County__c
 
Note: the state value in the State__c field in the County__c object is automatically populated in the State__c field (formula: County__r.State__r.Name)  in the Judgment_Event__c object. – thanks for your advice.
 
AND
 
Within the Judgment_Exp_Matrix__c object, when a user selects the values below
“Recording” in Action_Type__c (picklist)
“County” in Recording_Location__c  (picklist)
number in the Years__c
State value within the State1__c (example: this is the same state in the State__c formula(text) field in the Judgment_Event__c object ).
 
I would like the number in Years__c to add with the date in Recording_Date__c in Judgment_Event__c , and the final calculation will be automatically populate in the Expiration_Date__c.  For example: if the date in the Recording_Date__c is 1/01/2012 and a user selects the number 2 in the Years__c field, 1/01/2014 will be automatically populated in the Expiration_Date__c
 
Note: Just a reminder, in the Judgment_Event__c object, the State value in the State__c formula(text) field has to be the same state in the  State1__c in Judgment_Exp_Matrix__c . Also the value “Recording” needs to be the same in the Action_Type__c  fields in both the Judgment_Event__c and the Judgment_Exp_Matrix__c objects. Also the value “County” needs to be the same in the Recording_Location__c fields in both the Judgment_Event__c and the Judgment_Exp_Matrix__c objects.     If criteria is not met, then the trigger should not initiate.


Here are the screen shot for the 2 records in the Judgment_Event__c and Judgment_Exp_Matrix__c objects.

User-added image

User-added image
 
Balaji Chowdary GarapatiBalaji Chowdary Garapati
Can you add a debug log and share it! so that i can see whats going on!

Thanks,
Balaji
Forrest MulduneForrest Muldune
Sorry but how do I create a debug log for this trigger?
Balaji Chowdary GarapatiBalaji Chowdary Garapati
Go to setup>Logs>Debug log,

Click new, in the look up choose your user record. Now go to the JE record and try to save, the debug log will capture all the actions performed then.
For more info:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_debugging_debug_log.htm

Thanks,
balaji
Forrest MulduneForrest Muldune
here are the logs below.


32.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO 14:41:46.018 (18332726)|EXECUTION_STARTED 14:41:46.018 (18403299)|CODE_UNIT_STARTED|[EXTERNAL]|VisualForce View State 14:41:46.024 (24267100)|CODE_UNIT_FINISHED|VisualForce View State 14:41:46.026 (26270954)|EXECUTION_FINISHED


here is another one



32.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO 14:43:32.028 (28137744)|EXECUTION_STARTED 14:43:32.028 (28183585)|CODE_UNIT_STARTED|[EXTERNAL]|VisualForce View State 14:43:32.036 (36409326)|CODE_UNIT_FINISHED|VisualForce View State 14:43:32.038 (38774421)|EXECUTION_FINISHED 14:43:32.723 (544934293)|CUMULATIVE_LIMIT_USAGE 14:43:32.723|LIMIT_USAGE_FOR_NS|(default)| Number of SOQL queries: 0 out of 100 Number of query rows: 0 out of 50000 Number of SOSL queries: 0 out of 20 Number of DML statements: 0 out of 150 Number of DML rows: 0 out of 10000 Maximum CPU time: 0 out of 10000 Maximum heap size: 0 out of 6000000 Number of callouts: 0 out of 100 Number of Email Invocations: 0 out of 10 Number of future calls: 0 out of 50 Number of queueable jobs added to the queue: 0 out of 50 Number of Mobile Apex push calls: 0 out of 10 14:43:32.723|CUMULATIVE_LIMIT_USAGE_END

here is another one

32.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO 14:42:44.093 (93831180)|EXECUTION_STARTED 14:42:44.093 (93875343)|CODE_UNIT_STARTED|[EXTERNAL]|TRIGGERS 14:42:44.093 (93910195)|CODE_UNIT_STARTED|[EXTERNAL]|01qe00000004iyt|NewYear4 on Judgment_Event trigger event BeforeUpdate for [a0Qe0000003pH6m] 14:42:44.093 (93967754)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8 14:42:44.094 (94050999)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8 14:42:44.094 (94569885)|HEAP_ALLOCATE|[71]|Bytes:3 14:42:44.094 (94599484)|HEAP_ALLOCATE|[76]|Bytes:152 14:42:44.094 (94618697)|HEAP_ALLOCATE|[272]|Bytes:408 14:42:44.094 (94642842)|HEAP_ALLOCATE|[285]|Bytes:408 14:42:44.094 (94666146)|HEAP_ALLOCATE|[379]|Bytes:48 14:42:44.094 (94696121)|HEAP_ALLOCATE|[131]|Bytes:6 14:42:44.094 (94851822)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:28 14:42:44.094 (94870126)|VARIABLE_SCOPE_BEGIN|[1]|this|NewYear4|true|false 14:42:44.099 (99473681)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x72b7e6ba 14:42:44.099 (99544205)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:28 14:42:44.099 (99557067)|VARIABLE_SCOPE_BEGIN|[1]|this|NewYear4|true|false 14:42:44.102 (102738325)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x72b7e6ba 14:42:44.102 (102754127)|STATEMENT_EXECUTE|[1] 14:42:44.102 (102758428)|STATEMENT_EXECUTE|[5] 14:42:44.102 (102770110)|HEAP_ALLOCATE|[5]|Bytes:4 14:42:44.102 (102803805)|SYSTEM_CONSTRUCTOR_ENTRY|[5]|<init>(Integer) 14:42:44.102 (102834026)|SYSTEM_CONSTRUCTOR_EXIT|[5]|<init>(Integer) 14:42:44.102 (102880391)|HEAP_ALLOCATE|[50]|Bytes:5 14:42:44.102 (102906466)|HEAP_ALLOCATE|[56]|Bytes:5 14:42:44.102 (102918546)|HEAP_ALLOCATE|[63]|Bytes:7 14:42:44.105 (105979941)|VARIABLE_ASSIGNMENT|[5]|this.States_Set|{"serId":1,"value":[]}|0x72b7e6ba 14:42:44.105 (105996644)|STATEMENT_EXECUTE|[6] 14:42:44.106 (106009874)|HEAP_ALLOCATE|[6]|Bytes:4 14:42:44.109 (109131179)|VARIABLE_ASSIGNMENT|[6]|this.JEStateMap|{"serId":1,"value":{}}|0x72b7e6ba 14:42:44.109 (109145186)|STATEMENT_EXECUTE|[7] 14:42:44.109 (109154421)|HEAP_ALLOCATE|[7]|Bytes:4 14:42:44.114 (114147482)|VARIABLE_ASSIGNMENT|[7]|this.CountyStateYearMap|{"serId":1,"value":{}}|0x72b7e6ba 14:42:44.114 (114166455)|STATEMENT_EXECUTE|[8] 14:42:44.114 (114177992)|HEAP_ALLOCATE|[8]|Bytes:4 14:42:44.117 (117414578)|VARIABLE_ASSIGNMENT|[8]|this.OtherStateYearMap|{"serId":1,"value":{}}|0x72b7e6ba 14:42:44.117 (117431793)|STATEMENT_EXECUTE|[9] 14:42:44.117 (117444674)|HEAP_ALLOCATE|[9]|Bytes:4 14:42:44.120 (120481219)|VARIABLE_ASSIGNMENT|[9]|this.SecretaryStateYearMap|{"serId":1,"value":{}}|0x72b7e6ba 14:42:44.120 (120494049)|STATEMENT_EXECUTE|[10] 14:42:44.120 (120502871)|HEAP_ALLOCATE|[10]|Bytes:4 14:42:44.123 (123669430)|VARIABLE_ASSIGNMENT|[10]|this.CountyInfoMap|{"serId":1,"value":{}}|0x72b7e6ba 14:42:44.123 (123854884)|SYSTEM_METHOD_ENTRY|[12]|LIST<Judgment_Event__c>.iterator() 14:42:44.124 (124041853)|SYSTEM_METHOD_EXIT|[12]|LIST<Judgment_Event__c>.iterator() 14:42:44.124 (124073028)|SYSTEM_METHOD_ENTRY|[12]|system.ListIterator.hasNext() 14:42:44.124 (124099784)|HEAP_ALLOCATE|[12]|Bytes:5 14:42:44.124 (124109895)|SYSTEM_METHOD_EXIT|[12]|system.ListIterator.hasNext() 14:42:44.124 (124146376)|HEAP_ALLOCATE|[12]|Bytes:4 14:42:44.124 (124161791)|VARIABLE_SCOPE_BEGIN|[12]|JE|Judgment_Event__c|true|false 14:42:44.143 (143544060)|VARIABLE_ASSIGNMENT|[12]|JE|{"Action_Type__c":"Recording","LastModifiedById":"005i0000001tqvAAAQ","LastModifiedDate":"2015-01-06T20:05:16.000Z","Recording_Date__c":"2014-11-01T00:00:00.000Z","Name":"test","Judgment__c":"a0Je0000002yiwAEAQ","SystemModstamp":"2015-01-06T20:05:16.000Z","CreatedById":"005i0000001tqvAAAQ","CreatedDate":"2015-01-06T20:05:16.000Z","State__c":"Louisiana","IsDeleted":false,"Id":"a0Qe0000003pH6mEAE","County__c":"a0Re0000001InQNEA0","Recording_Location__ (1 more) ...":"County","Location__c":"Abbeville County, Lo (7 more) ..."}|0x1a94bc16 14:42:44.143 (143585337)|STATEMENT_EXECUTE|[12] 14:42:44.143 (143640013)|HEAP_ALLOCATE|[13]|Bytes:9 14:42:44.143 (143693816)|STATEMENT_EXECUTE|[13] 14:42:44.143 (143734750)|HEAP_ALLOCATE|[14]|Bytes:6 14:42:44.143 (143761582)|STATEMENT_EXECUTE|[14] 14:42:44.143 (143815555)|STATEMENT_EXECUTE|[16] 14:42:44.143 (143872216)|HEAP_ALLOCATE|[16]|Bytes:4 14:42:44.144 (144133498)|SYSTEM_METHOD_ENTRY|[16]|MAP<Id,County__c>.put(Object, Object) 14:42:44.144 (144192886)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:-4 14:42:44.144 (144226646)|SYSTEM_METHOD_EXIT|[16]|MAP<Id,County__c>.put(Object, Object) 14:42:44.144 (144250003)|HEAP_ALLOCATE|[18]|Bytes:18 14:42:44.144 (144283105)|HEAP_ALLOCATE|[18]|Bytes:18 14:42:44.144 (144309631)|STATEMENT_EXECUTE|[18] 14:42:44.144 (144331652)|SYSTEM_METHOD_ENTRY|[12]|system.ListIterator.hasNext() 14:42:44.144 (144358638)|HEAP_ALLOCATE|[12]|Bytes:5 14:42:44.144 (144376241)|SYSTEM_METHOD_EXIT|[12]|system.ListIterator.hasNext() 14:42:44.147 (147628163)|VARIABLE_ASSIGNMENT|[12]|JE|null| 14:42:44.147 (147647476)|HEAP_ALLOCATE|[26]|Bytes:59 14:42:44.147 (147661315)|HEAP_ALLOCATE|[26]|Bytes:4 14:42:44.147 (147674125)|HEAP_ALLOCATE|[26]|Bytes:7 14:42:44.147 (147723891)|SYSTEM_METHOD_ENTRY|[26]|MAP<Id,County__c>.keySet() 14:42:44.147 (147822797)|HEAP_ALLOCATE|[26]|Bytes:26 14:42:44.147 (147839629)|SYSTEM_METHOD_EXIT|[26]|MAP<Id,County__c>.keySet() 14:42:44.148 (148346924)|SOQL_EXECUTE_BEGIN|[26]|Aggregations:0|select id, state__r.Name from county__c 14:42:44.153 (153509322)|SOQL_EXECUTE_END|[26]|Rows:1 14:42:44.153 (153530737)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8 14:42:44.153 (153589768)|SYSTEM_METHOD_ENTRY|[26]|Database.QueryLocator.iterator() 14:42:44.153 (153779793)|HEAP_ALLOCATE|[26]|Bytes:33 14:42:44.153 (153801430)|HEAP_ALLOCATE|[26]|Bytes:8 14:42:44.153 (153831853)|SYSTEM_METHOD_ENTRY|[7]|QueryLocatorIterator.QueryLocatorIterator() 14:42:44.153 (153845671)|STATEMENT_EXECUTE|[7] 14:42:44.153 (153862608)|SYSTEM_METHOD_EXIT|[7]|QueryLocatorIterator 14:42:44.153 (153876848)|HEAP_ALLOCATE|[26]|Bytes:28 14:42:44.153 (153946945)|HEAP_ALLOCATE|[26]|Bytes:8 14:42:44.153 (153975170)|HEAP_ALLOCATE|[26]|Bytes:8 14:42:44.153 (153984566)|HEAP_ALLOCATE|[26]|Bytes:8 14:42:44.153 (153997094)|VARIABLE_SCOPE_BEGIN|[15]|this|Database.QueryLocatorIterator|true|false 14:42:44.157 (157860401)|VARIABLE_ASSIGNMENT|[15]|this|{}|0x433e7373 14:42:44.157 (157876239)|VARIABLE_SCOPE_BEGIN|[15]|values|LIST<SObject>|true|false 14:42:44.162 (162180856)|VARIABLE_ASSIGNMENT|[15]|values|{"serId":1,"value":[{"serId":2,"value":{"State__r":{"serId":3,"value":{"Name":"Louisiana","Id":"a0Te0000008XGAAEA4"}},"State__c":"a0Te0000008XGAAEA4","Id":"a0Re0000001InQNEA0"}}]}|0x5d44886f 14:42:44.162 (162197730)|VARIABLE_SCOPE_BEGIN|[15]|ql|Database.QueryLocator|true|false 14:42:44.165 (165315605)|VARIABLE_ASSIGNMENT|[15]|ql|{"query":"select id, state__r. (39 more) ..."}|0x23941c94 14:42:44.165 (165333750)|VARIABLE_SCOPE_BEGIN|[15]|totalNumRecords|Integer|false|false 14:42:44.168 (168473518)|VARIABLE_ASSIGNMENT|[15]|totalNumRecords|1 14:42:44.168 (168492850)|VARIABLE_SCOPE_BEGIN|[15]|queryMoreSize|Integer|false|false 14:42:44.171 (171440641)|VARIABLE_ASSIGNMENT|[15]|queryMoreSize|49999 14:42:44.171 (171477810)|HEAP_ALLOCATE|[13]|Bytes:6 14:42:44.171 (171530810)|VARIABLE_SCOPE_BEGIN|[2]|this|system.ApexBaseClass|true|false 14:42:44.174 (174677013)|VARIABLE_ASSIGNMENT|[2]|this|{}|0x433e7373 14:42:44.177 (177850508)|VARIABLE_ASSIGNMENT|[16]|this.ql|{"query":"select id, state__r. (39 more) ..."}|0x433e7373 14:42:44.180 (180893371)|VARIABLE_ASSIGNMENT|[17]|this.totalNumRecords|1|0x433e7373 14:42:44.180 (180917779)|HEAP_ALLOCATE|[18]|Bytes:4 14:42:44.183 (183876782)|VARIABLE_ASSIGNMENT|[18]|this.count|0|0x433e7373 14:42:44.183 (183894545)|HEAP_ALLOCATE|[19]|Bytes:4 14:42:44.187 (187074471)|VARIABLE_ASSIGNMENT|[19]|this.index|0|0x433e7373 14:42:44.190 (190118558)|VARIABLE_ASSIGNMENT|[20]|this.buffer|null|0x433e7373 14:42:44.193 (193193864)|VARIABLE_ASSIGNMENT|[21]|this.buffer|{"serId":1,"value":[{"serId":2,"value":{"State__r":{"serId":3,"value":{"Name":"Louisiana","Id":"a0Te0000008XGAAEA4"}},"State__c":"a0Te0000008XGAAEA4","Id":"a0Re0000001InQNEA0"}}]}|0x433e7373 14:42:44.196 (196222510)|VARIABLE_ASSIGNMENT|[22]|this.queryMoreSize|49999|0x433e7373 14:42:44.196 (196256406)|HEAP_ALLOCATE|[26]|Bytes:28 14:42:44.196 (196280784)|SYSTEM_METHOD_EXIT|[26]|Database.QueryLocator.iterator() 14:42:44.196 (196314958)|SYSTEM_METHOD_ENTRY|[26]|Database.QueryLocatorIterator.hasNext() 14:42:44.196 (196334560)|VARIABLE_SCOPE_BEGIN|[25]|this|Database.QueryLocatorIterator|true|false 14:42:44.199 (199478005)|VARIABLE_ASSIGNMENT|[25]|this|{"buffer":"0x5d44886f","count":0,"index":0,"ql":{"query":"select id, state__r. (39 more) ..."},"queryMoreSize":49999,"totalNumRecords":1}|0x433e7373 14:42:44.199 (199597147)|SYSTEM_METHOD_ENTRY|[35]|LIST<County__c>.size() 14:42:44.199 (199652138)|SYSTEM_METHOD_EXIT|[35]|LIST<County__c>.size() 14:42:44.199 (199673260)|SYSTEM_METHOD_EXIT|[26]|Database.QueryLocatorIterator.hasNext() 14:42:44.199 (199691892)|SYSTEM_METHOD_ENTRY|[26]|Database.QueryLocatorIterator.next() 14:42:44.199 (199708361)|VARIABLE_SCOPE_BEGIN|[49]|this|Database.QueryLocatorIterator|true|false 14:42:44.202 (202649822)|VARIABLE_ASSIGNMENT|[49]|this|{"buffer":"0x5d44886f","count":0,"index":0,"ql":{"query":"select id, state__r. (39 more) ..."},"queryMoreSize":49999,"totalNumRecords":1}|0x433e7373 14:42:44.202 (202683014)|SYSTEM_METHOD_ENTRY|[50]|Database.QueryLocatorIterator.hasNext() 14:42:44.202 (202706498)|VARIABLE_SCOPE_BEGIN|[25]|this|Database.QueryLocatorIterator|true|false 14:42:44.205 (205594570)|VARIABLE_ASSIGNMENT|[25]|this|{"buffer":"0x5d44886f","count":0,"index":0,"ql":{"query":"select id, state__r. (39 more) ..."},"queryMoreSize":49999,"totalNumRecords":1}|0x433e7373 14:42:44.205 (205625547)|SYSTEM_METHOD_ENTRY|[35]|LIST<County__c>.size() 14:42:44.205 (205638383)|SYSTEM_METHOD_EXIT|[35]|LIST<County__c>.size() 14:42:44.205 (205648738)|SYSTEM_METHOD_EXIT|[50]|Database.QueryLocatorIterator.hasNext() 14:42:44.205 (205692662)|HEAP_ALLOCATE|[55]|Bytes:16 14:42:44.205 (205707152)|VARIABLE_SCOPE_BEGIN|[55]|retval|SObject|true|false 14:42:44.208 (208637318)|VARIABLE_ASSIGNMENT|[55]|retval|{"serId":1,"value":{"State__r":{"serId":2,"value":{"Name":"Louisiana","Id":"a0Te0000008XGAAEA4"}},"State__c":"a0Te0000008XGAAEA4","Id":"a0Re0000001InQNEA0"}}|0x3e595f3f 14:42:44.208 (208658375)|HEAP_ALLOCATE|[56]|Bytes:4 14:42:44.211 (211548194)|VARIABLE_ASSIGNMENT|[56]|this.index|1|0x433e7373 14:42:44.211 (211570364)|HEAP_ALLOCATE|[57]|Bytes:4 14:42:44.215 (215171482)|VARIABLE_ASSIGNMENT|[57]|this.count|1|0x433e7373 14:42:44.215 (215195064)|SYSTEM_METHOD_EXIT|[26]|Database.QueryLocatorIterator.next() 14:42:44.215 (215211638)|VARIABLE_SCOPE_BEGIN|[26]|countyRecord|County__c|true|false 14:42:44.218 (218358566)|VARIABLE_ASSIGNMENT|[26]|countyRecord|{"serId":1,"value":{"State__r":{"serId":2,"value":{"Name":"Louisiana","Id":"a0Te0000008XGAAEA4"}},"State__c":"a0Te0000008XGAAEA4","Id":"a0Re0000001InQNEA0"}}|0x3e595f3f 14:42:44.218 (218376736)|STATEMENT_EXECUTE|[26] 14:42:44.218 (218380778)|STATEMENT_EXECUTE|[27] 14:42:44.218 (218479555)|SYSTEM_METHOD_ENTRY|[27]|MAP<Id,County__c>.put(Object, Object) 14:42:44.218 (218533100)|SYSTEM_METHOD_EXIT|[27]|MAP<Id,County__c>.put(Object, Object) 14:42:44.218 (218540339)|STATEMENT_EXECUTE|[28] 14:42:44.218 (218672402)|SYSTEM_METHOD_ENTRY|[28]|SET<String>.add(Object) 14:42:44.218 (218696650)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 14:42:44.218 (218711131)|SYSTEM_METHOD_EXIT|[28]|SET<String>.add(Object) 14:42:44.218 (218722865)|SYSTEM_METHOD_ENTRY|[26]|Database.QueryLocatorIterator.hasNext() 14:42:44.218 (218736539)|VARIABLE_SCOPE_BEGIN|[25]|this|Database.QueryLocatorIterator|true|false 14:42:44.221 (221904148)|VARIABLE_ASSIGNMENT|[25]|this|{"buffer":"0x5d44886f","count":1,"index":1,"ql":{"query":"select id, state__r. (39 more) ..."},"queryMoreSize":49999,"totalNumRecords":1}|0x433e7373 14:42:44.221 (221932312)|SYSTEM_METHOD_EXIT|[26]|Database.QueryLocatorIterator.hasNext() 14:42:44.225 (225058603)|VARIABLE_ASSIGNMENT|[26]|countyRecord|null| 14:42:44.225 (225099804)|HEAP_ALLOCATE|[33]|Bytes:145 14:42:44.225 (225117739)|HEAP_ALLOCATE|[33]|Bytes:4 14:42:44.226 (226970134)|SOQL_EXECUTE_BEGIN|[33]|Aggregations:0|select id, Years__c, Action_Type__c, State1__c, State1__r.Name, Recording_Location__c from Judgment_Exp_Matrix__c 14:42:44.235 (235663010)|SOQL_EXECUTE_END|[33]|Rows:1 14:42:44.235 (235685223)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8 14:42:44.235 (235752811)|SYSTEM_METHOD_ENTRY|[33]|Database.QueryLocator.iterator() 14:42:44.235 (235854226)|HEAP_ALLOCATE|[33]|Bytes:28 14:42:44.235 (235957178)|HEAP_ALLOCATE|[33]|Bytes:8 14:42:44.235 (235975600)|HEAP_ALLOCATE|[33]|Bytes:8 14:42:44.235 (235980184)|HEAP_ALLOCATE|[33]|Bytes:8 14:42:44.235 (235989641)|VARIABLE_SCOPE_BEGIN|[15]|this|Database.QueryLocatorIterator|true|false 14:42:44.239 (239362009)|VARIABLE_ASSIGNMENT|[15]|this|{}|0x2bb67f99 14:42:44.239 (239375878)|VARIABLE_SCOPE_BEGIN|[15]|values|LIST<SObject>|true|false 14:42:44.242 (242513399)|VARIABLE_ASSIGNMENT|[15]|values|{"serId":1,"value":[{"serId":2,"value":{"Action_Type__c":"Recording","State1__r":{"serId":3,"value":{"Name":"Louisiana","Id":"a0Te0000008XGAAEA4"}},"State1__c":"a0Te0000008XGAAEA4","Id":"a0Ue0000003qfzpEAA","Recording_Location__ (1 more) ...":"County","Years__c":2}}]}|0x5a732c3a 14:42:44.242 (242534421)|VARIABLE_SCOPE_BEGIN|[15]|ql|Database.QueryLocator|true|false 14:42:44.245 (245667181)|VARIABLE_ASSIGNMENT|[15]|ql|{"query":"select id, Years__c, (125 more) ..."}|0x2f25a123 14:42:44.245 (245680878)|VARIABLE_SCOPE_BEGIN|[15]|totalNumRecords|Integer|false|false 14:42:44.248 (248716470)|VARIABLE_ASSIGNMENT|[15]|totalNumRecords|1 14:42:44.248 (248735720)|VARIABLE_SCOPE_BEGIN|[15]|queryMoreSize|Integer|false|false 14:42:44.251 (251674116)|VARIABLE_ASSIGNMENT|[15]|queryMoreSize|49998 14:42:44.251 (251697848)|VARIABLE_SCOPE_BEGIN|[2]|this|system.ApexBaseClass|true|false 14:42:44.254 (254672442)|VARIABLE_ASSIGNMENT|[2]|this|{}|0x2bb67f99 14:42:44.257 (257793268)|VARIABLE_ASSIGNMENT|[16]|this.ql|{"query":"select id, Years__c, (125 more) ..."}|0x2bb67f99 14:42:44.260 (260775182)|VARIABLE_ASSIGNMENT|[17]|this.totalNumRecords|1|0x2bb67f99 14:42:44.260 (260796596)|HEAP_ALLOCATE|[18]|Bytes:4 14:42:44.264 (264262117)|VARIABLE_ASSIGNMENT|[18]|this.count|0|0x2bb67f99 14:42:44.264 (264279507)|HEAP_ALLOCATE|[19]|Bytes:4 14:42:44.267 (267418833)|VARIABLE_ASSIGNMENT|[19]|this.index|0|0x2bb67f99 14:42:44.270 (270314292)|VARIABLE_ASSIGNMENT|[20]|this.buffer|null|0x2bb67f99 14:42:44.273 (273510601)|VARIABLE_ASSIGNMENT|[21]|this.buffer|{"serId":1,"value":[{"serId":2,"value":{"Action_Type__c":"Recording","State1__r":{"serId":3,"value":{"Name":"Louisiana","Id":"a0Te0000008XGAAEA4"}},"State1__c":"a0Te0000008XGAAEA4","Id":"a0Ue0000003qfzpEAA","Recording_Location__ (1 more) ...":"County","Years__c":2}}]}|0x2bb67f99 14:42:44.276 (276467081)|VARIABLE_ASSIGNMENT|[22]|this.queryMoreSize|49998|0x2bb67f99 14:42:44.276 (276502216)|HEAP_ALLOCATE|[33]|Bytes:28 14:42:44.276 (276522485)|SYSTEM_METHOD_EXIT|[33]|Database.QueryLocator.iterator() 14:42:44.276 (276560843)|SYSTEM_METHOD_ENTRY|[33]|Database.QueryLocatorIterator.hasNext() 14:42:44.276 (276579811)|VARIABLE_SCOPE_BEGIN|[25]|this|Database.QueryLocatorIterator|true|false 14:42:44.279 (279557603)|VARIABLE_ASSIGNMENT|[25]|this|{"buffer":"0x5a732c3a","count":0,"index":0,"ql":{"query":"select id, Years__c, (125 more) ..."},"queryMoreSize":49998,"totalNumRecords":1}|0x2bb67f99 14:42:44.279 (279675695)|SYSTEM_METHOD_ENTRY|[35]|LIST<Judgment_Exp_Matrix__c>.size() 14:42:44.279 (279699180)|SYSTEM_METHOD_EXIT|[35]|LIST<Judgment_Exp_Matrix__c>.size() 14:42:44.279 (279721130)|SYSTEM_METHOD_EXIT|[33]|Database.QueryLocatorIterator.hasNext() 14:42:44.279 (279739944)|SYSTEM_METHOD_ENTRY|[33]|Database.QueryLocatorIterator.next() 14:42:44.279 (279755681)|VARIABLE_SCOPE_BEGIN|[49]|this|Database.QueryLocatorIterator|true|false 14:42:44.282 (282546922)|VARIABLE_ASSIGNMENT|[49]|this|{"buffer":"0x5a732c3a","count":0,"index":0,"ql":{"query":"select id, Years__c, (125 more) ..."},"queryMoreSize":49998,"totalNumRecords":1}|0x2bb67f99 14:42:44.282 (282578184)|SYSTEM_METHOD_ENTRY|[50]|Database.QueryLocatorIterator.hasNext() 14:42:44.282 (282587831)|VARIABLE_SCOPE_BEGIN|[25]|this|Database.QueryLocatorIterator|true|false 14:42:44.285 (285551963)|VARIABLE_ASSIGNMENT|[25]|this|{"buffer":"0x5a732c3a","count":0,"index":0,"ql":{"query":"select id, Years__c, (125 more) ..."},"queryMoreSize":49998,"totalNumRecords":1}|0x2bb67f99 14:42:44.285 (285581514)|SYSTEM_METHOD_ENTRY|[35]|LIST<Judgment_Exp_Matrix__c>.size() 14:42:44.285 (285593325)|SYSTEM_METHOD_EXIT|[35]|LIST<Judgment_Exp_Matrix__c>.size() 14:42:44.285 (285603413)|SYSTEM_METHOD_EXIT|[50]|Database.QueryLocatorIterator.hasNext() 14:42:44.285 (285661275)|HEAP_ALLOCATE|[55]|Bytes:28 14:42:44.285 (285674627)|VARIABLE_SCOPE_BEGIN|[55]|retval|SObject|true|false 14:42:44.288 (288631190)|VARIABLE_ASSIGNMENT|[55]|retval|{"serId":1,"value":{"Action_Type__c":"Recording","State1__r":{"serId":2,"value":{"Name":"Louisiana","Id":"a0Te0000008XGAAEA4"}},"State1__c":"a0Te0000008XGAAEA4","Id":"a0Ue0000003qfzpEAA","Recording_Location__ (1 more) ...":"County","Years__c":2}}|0x3f5cc23a 14:42:44.288 (288656619)|HEAP_ALLOCATE|[56]|Bytes:4 14:42:44.291 (291647108)|VARIABLE_ASSIGNMENT|[56]|this.index|1|0x2bb67f99 14:42:44.291 (291663528)|HEAP_ALLOCATE|[57]|Bytes:4 14:42:44.294 (294578981)|VARIABLE_ASSIGNMENT|[57]|this.count|1|0x2bb67f99 14:42:44.294 (294598545)|SYSTEM_METHOD_EXIT|[33]|Database.QueryLocatorIterator.next() 14:42:44.294 (294612616)|VARIABLE_SCOPE_BEGIN|[33]|JEM|Judgment_Exp_Matrix__c|true|false 14:42:44.297 (297750317)|VARIABLE_ASSIGNMENT|[33]|JEM|{"serId":1,"value":{"Action_Type__c":"Recording","State1__r":{"serId":2,"value":{"Name":"Louisiana","Id":"a0Te0000008XGAAEA4"}},"State1__c":"a0Te0000008XGAAEA4","Id":"a0Ue0000003qfzpEAA","Recording_Location__ (1 more) ...":"County","Years__c":2}}|0x3f5cc23a 14:42:44.297 (297774056)|STATEMENT_EXECUTE|[36] 14:42:44.297 (297877353)|STATEMENT_EXECUTE|[37] 14:42:44.297 (297943464)|STATEMENT_EXECUTE|[38] 14:42:44.298 (298010611)|STATEMENT_EXECUTE|[40] 14:42:44.298 (298227569)|SYSTEM_METHOD_ENTRY|[40]|Integer.valueOf(Object) 14:42:44.298 (298306233)|SYSTEM_METHOD_EXIT|[40]|Integer.valueOf(Object) 14:42:44.298 (298355367)|SYSTEM_METHOD_ENTRY|[40]|MAP<String,Integer>.put(Object, Object) 14:42:44.298 (298371060)|HEAP_ALLOCATE|[40]|Bytes:4 14:42:44.298 (298385601)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:-4 14:42:44.298 (298415069)|SYSTEM_METHOD_EXIT|[40]|MAP<String,Integer>.put(Object, Object) 14:42:44.298 (298450548)|STATEMENT_EXECUTE|[42] 14:42:44.298 (298477037)|STATEMENT_EXECUTE|[46] 14:42:44.298 (298497333)|SYSTEM_METHOD_ENTRY|[33]|Database.QueryLocatorIterator.hasNext() 14:42:44.298 (298520517)|VARIABLE_SCOPE_BEGIN|[25]|this|Database.QueryLocatorIterator|true|false 14:42:44.301 (301755510)|VARIABLE_ASSIGNMENT|[25]|this|{"buffer":"0x5a732c3a","count":1,"index":1,"ql":{"query":"select id, Years__c, (125 more) ..."},"queryMoreSize":49998,"totalNumRecords":1}|0x2bb67f99 14:42:44.301 (301799423)|SYSTEM_METHOD_EXIT|[33]|Database.QueryLocatorIterator.hasNext() 14:42:44.304 (304767683)|VARIABLE_ASSIGNMENT|[33]|JEM|null| 14:42:44.304 (304854279)|SYSTEM_METHOD_ENTRY|[55]|LIST<Judgment_Event__c>.iterator() 14:42:44.304 (304904473)|SYSTEM_METHOD_EXIT|[55]|LIST<Judgment_Event__c>.iterator() 14:42:44.304 (304921005)|SYSTEM_METHOD_ENTRY|[55]|system.ListIterator.hasNext() 14:42:44.304 (304948233)|HEAP_ALLOCATE|[55]|Bytes:5 14:42:44.304 (304960380)|SYSTEM_METHOD_EXIT|[55]|system.ListIterator.hasNext() 14:42:44.304 (304983067)|HEAP_ALLOCATE|[55]|Bytes:4 14:42:44.304 (304999756)|VARIABLE_SCOPE_BEGIN|[55]|JE|Judgment_Event__c|true|false 14:42:44.308 (308338164)|VARIABLE_ASSIGNMENT|[55]|JE|{"Action_Type__c":"Recording","LastModifiedById":"005i0000001tqvAAAQ","LastModifiedDate":"2015-01-06T20:05:16.000Z","Recording_Date__c":"2014-11-01T00:00:00.000Z","Name":"test","Judgment__c":"a0Je0000002yiwAEAQ","SystemModstamp":"2015-01-06T20:05:16.000Z","CreatedById":"005i0000001tqvAAAQ","CreatedDate":"2015-01-06T20:05:16.000Z","State__c":"Louisiana","IsDeleted":false,"Id":"a0Qe0000003pH6mEAE","County__c":"a0Re0000001InQNEA0","Recording_Location__ (1 more) ...":"County","Location__c":"Abbeville County, Lo (7 more) ..."}|0x1a94bc16 14:42:44.308 (308360036)|STATEMENT_EXECUTE|[55] 14:42:44.308 (308407401)|STATEMENT_EXECUTE|[56] 14:42:44.308 (308460012)|STATEMENT_EXECUTE|[57] 14:42:44.308 (308497742)|SYSTEM_METHOD_ENTRY|[58]|MAP<String,Integer>.keySet() 14:42:44.308 (308567021)|HEAP_ALLOCATE|[58]|Bytes:17 14:42:44.308 (308578752)|SYSTEM_METHOD_EXIT|[58]|MAP<String,Integer>.keySet() 14:42:44.308 (308615775)|SYSTEM_METHOD_ENTRY|[58]|MAP<Id,County__c>.get(Object) 14:42:44.308 (308640620)|SYSTEM_METHOD_EXIT|[58]|MAP<Id,County__c>.get(Object) 14:42:44.308 (308675599)|SYSTEM_METHOD_ENTRY|[58]|SET<String>.contains(Object) 14:42:44.308 (308691442)|SYSTEM_METHOD_EXIT|[58]|SET<String>.contains(Object) 14:42:44.308 (308698315)|STATEMENT_EXECUTE|[59] 14:42:44.308 (308727548)|SYSTEM_METHOD_ENTRY|[59]|MAP<Id,County__c>.get(Object) 14:42:44.308 (308758077)|SYSTEM_METHOD_EXIT|[59]|MAP<Id,County__c>.get(Object) 14:42:44.308 (308782105)|SYSTEM_METHOD_ENTRY|[59]|MAP<String,Integer>.get(Object) 14:42:44.308 (308798050)|SYSTEM_METHOD_EXIT|[59]|MAP<String,Integer>.get(Object) 14:42:44.308 (308838701)|SYSTEM_METHOD_ENTRY|[59]|com.salesforce.api.interop.apex.bcl.DateMethods.addYears(Integer) 14:42:44.308 (308867890)|HEAP_ALLOCATE|[59]|Bytes:4 14:42:44.308 (308881389)|SYSTEM_METHOD_EXIT|[59]|com.salesforce.api.interop.apex.bcl.DateMethods.addYears(Integer) 14:42:44.312 (312103669)|VARIABLE_ASSIGNMENT|[59]|this.Expiration_Date__c|"2016-11-01T00:00:00.000Z"|0x1a94bc16 14:42:44.312 (312147800)|STATEMENT_EXECUTE|[61] 14:42:44.312 (312176656)|STATEMENT_EXECUTE|[66] 14:42:44.312 (312201984)|SYSTEM_METHOD_ENTRY|[55]|system.ListIterator.hasNext() 14:42:44.312 (312229139)|HEAP_ALLOCATE|[55]|Bytes:5 14:42:44.312 (312247831)|SYSTEM_METHOD_EXIT|[55]|system.ListIterator.hasNext() 14:42:44.315 (315106392)|VARIABLE_ASSIGNMENT|[55]|JE|null| 14:42:44.989 (315143791)|CUMULATIVE_LIMIT_USAGE 14:42:44.989|LIMIT_USAGE_FOR_NS|(default)| Number of SOQL queries: 2 out of 100 Number of query rows: 2 out of 50000 Number of SOSL queries: 0 out of 20 Number of DML statements: 0 out of 150 Number of DML rows: 0 out of 10000 Maximum CPU time: 0 out of 10000 Maximum heap size: 0 out of 6000000 Number of callouts: 0 out of 100 Number of Email Invocations: 0 out of 10 Number of future calls: 0 out of 50 Number of queueable jobs added to the queue: 0 out of 50 Number of Mobile Apex push calls: 0 out of 10 14:42:44.989|CUMULATIVE_LIMIT_USAGE_END 14:42:44.315 (315268446)|CODE_UNIT_FINISHED|NewYear4 on Judgment_Event trigger event BeforeUpdate for [a0Qe0000003pH6m] 14:42:44.358 (358853754)|CODE_UNIT_FINISHED|TRIGGERS 14:42:44.358 (358874987)|EXECUTION_FINISHED






 
Balaji Chowdary GarapatiBalaji Chowdary Garapati
can you try below code and send back the debug log once again, i dont see any issue but just to make sure
 
trigger NewYear on Judgment_Event__c (before insert,before update) {
/* 
Since we can not have the correct value of formula fields in before triggers, we need to fire a query to fetch the state information and the record it belongs to.
*/
    Set<String> States_Set=new Set<String>();//This is to collect all the states from the records on which the trigger fired.
	Map<Id,String>JEStateMap=new Map<Id,String>();//This is to collect the id of JE record and the state it needs to be used
	Map<String,Integer>CountyStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State in County record
	Map<String,Integer>OtherStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State if other state is selected
	Map<String,Integer>SecretaryStateYearMap=new Map<String,Integer>();//This is to collect all the information necessary based on State if secretary state is selected
	Map<Id,County__c>CountyInfoMap=new Map<Id,County__c>();//To collect all the information related to county
	Set<Id>CountyIds=new Set<Id>();
	system.debug('JE Information ***'+Trigger.new);
    for(Judgment_Event__c JE: Trigger.new){
        if(je.Action_Type__c == 'Recording' ) {
			 if(JE.Recording_Location__c=='County'){
			     if(JE.County__c!=Null)
				 CountyIds.add(JE.County__c);
			     
			 }
	         if(JE.Recording_Location__c=='Other State Office' || JE.Recording_Location__c=='Secretary of State'){
			    if(JE.Recording_Office_State__c!=Null)
				States_Set.add(JE.Recording_Office_State__c);
			 
			 }
	     }	
	}// By End of this for loop, we will have the county id information, states from Recording_Office_State__c based on conditions.
	system.debug('*** States_Set, CountyIds'+States_Set+'**'+CountyIds);
	//Time to query county and get the required state information and add it to our state list
	for(County__c countyRecord:[select id,state__r.Name From county__c where id iN :CountyIds]){
	  CountyInfoMap.put(countyRecord.id,countyRecord);
	  States_Set.add(countyRecord.state__r.Name);
	}
	//Now we have all the state information based on conditions, query the Judgment_Exp_Matrix__c and get corresponding year information.
	
	system.debug('*** States_Set, CountyInfoMap'+States_Set+'**'+CountyInfoMap);
	for(Judgment_Exp_Matrix__c JEM:[select id,Years__c,Action_Type__c,
											Recording_Location__c,State1__c,State1__r.Name,
											Recording_Location__c											
											from Judgment_Exp_Matrix__c where State1__r.Name IN :States_Set]){
	    if(JEM.Action_Type__c == 'Recording'){
			IF(JEM.Recording_Location__c=='County'  ) {
				if(JEM.Years__c!=Null)
			   CountyStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
			If(JEM.Recording_Location__c == 'Other State Office' ) {
				if(JEM.Years__c!=Null)
				OtherStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
			If(JEM.Recording_Location__c == 'Secretary of State' ) {
				if(JEM.Years__c!=Null)
				SecretaryStateYearMap.put(JEM.State1__r.Name,Integer.valueof(JEM.Years__c));
			}
		
		}
	}// By end of this loop we will have all the information grouped on our conditions, its time to add the years to the Recording_Date__c 
	
	system.debug('Maps Coming as'+'**+CountyStateYearMap+'***'+OtherStateYearMap+'***'+SecretaryStateYearMap);
	
	 for(Judgment_Event__c JE: Trigger.new){
        if(je.Action_Type__c == 'Recording' ) {
			 if(JE.Recording_Location__c=='County' && JE.County__c!=Null && JE.Recording_Date__c!=Null){
					if(CountyStateYearMap.keyset().contains(CountyInfoMap.get(JE.County__c).state__r.Name))
					JE.Expiration_Date__c=JE.Recording_Date__c.addYears(CountyStateYearMap.get(CountyInfoMap.get(JE.County__c).state__r.Name));
			 }
	         if(JE.Recording_Location__c=='Other State Office' && JE.Recording_Office_State__c!=Null && JE.Recording_Date__c!=Null){
				if(OtherStateYearMap.keyset().contains(JE.Recording_Office_State__c))
			    JE.Expiration_Date__c=JE.Recording_Date__c.addYears(OtherStateYearMap.get(JE.Recording_Office_State__c));
			 
			 }
			 if(JE.Recording_Location__c=='Secretary of State'&& JE.Recording_Office_State__c!=Null && JE.Recording_Date__c!=Null ){
				if(SecretaryStateYearMap.keyset().contains(JE.Recording_Office_State__c))
			    JE.Expiration_Date__c=JE.Recording_Date__c.addYears(SecretaryStateYearMap.get(JE.Recording_Office_State__c));
			 
			 }
	     }	

system.debug('JE Final date for id **'+JE.Id+'***'+JE.Expiration_Date__c);
	}// By end of this loop we will have the expiration date populated based on conditions.
	
	system.debug('JE Final INFO ****'+trigger.new);
	
	
}

 
This was selected as the best answer
Forrest MulduneForrest Muldune
I pasted the code back into the apex trigger but now I have error message below.

User-added image
Balaji Chowdary GarapatiBalaji Chowdary Garapati
please add a quote after the 2 star's in line no 57
Forrest MulduneForrest Muldune
Magnificent! The coding for action 1 works now, let me check for Action 2 and 3.

 
Forrest MulduneForrest Muldune
I noticed when I change the number in the Years__c field in Judgment_Exp_Matrix__c object, the value in the date in the Expiration_Date__c in the Judgment_Event__c object does not re calculate.

Example: when I change the number from 2 to 3 in the years field and save the record, the  value in the Expiration_Date__c  does not recalculate when the changes are made. This happens to all actions.

Sorry for sending you so many messages.
Balaji Chowdary GarapatiBalaji Chowdary Garapati
For that you need to have an other trigger on JEM, to have those recalculated on JE. 
Forrest MulduneForrest Muldune
Ok, I understand , thank you very much. I am test all the actions now.
Forrest MulduneForrest Muldune
Balaji,

Thank you very, very , very much for your help and support. The trigger works great and now I am going to try to create other triggers for our App. As you can see I am a beginner in Apex and currently I am taking some begginer Java courses to enhance my skills in programming.

Do you know of any practical beginner websites to learn Apex and Java?

Once again, thank you for everything.

Forrest

 
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@Forrest,

 you are welcome! Try completing all the work books from below link:

https://developer.salesforce.com/page/Force.com_workbook

They will help a lot and you can also follow the below channel:

https://www.youtube.com/user/DeveloperForce/videos


These are great and i started with those to begin with & still following those videos for updated content!

Thanks,
balaji
Forrest MulduneForrest Muldune
balaji,

Thank you for the resources. I will take a look at the workbooks now.

Take care.