title: Apex Trigger: Use a trigger to update a custom field with data from another object
body: <p>I am attempting to write a trigger and I relatively new to both Salesforce and Object oriented programming and I am struggling, so any help would be appreciated!</p>
  <p>Task Description:</p>
  <p>I have two custom objects, Employee, and Position Associate. Position Associate is an object that creates a mapping and record between an employee and a respective position that they hold. I am attempting to write a trigger, that runs any time a Position Associate is created or updated, that takes three fields, Training Start, Training End, and Home Study Start, and populates it with data from the employee object, from the employee that is mapped to the Position Associate record in question. This must be a trigger as opposed to a making the field a lookup value. So while that may be simpler, it is not an option in this scenario</p>
  <p>Current Behavior: While I am not getting any errors, after a record is updated, the fields still remain blank.</p>
  <p>Code:</p>
  <pre><code>trigger MapDatesPA on Position_Employee__c (after insert,after update)
  // Create trigger that runs when a new record is inserted or when a record is updated that maps the employee fields //of Home Study Start Date, Training Start and End Dates to Position Assoicate Object
  {
  //Prevent Iterative Loop 
  if(checkRecursive.runOnce()){ 
                Map&lt;Id,Employee__c&gt; pm = new Map &lt;Id,_Employee__c&gt;();
                Set&lt;Id&gt; empIds = new Set&lt;Id&gt;();
                for(Position_Employee__c posEmp: Trigger.new){
                  if(posEmp.Employee__c != null){
                    empIds.add(posEmp.Employee__c);
                  }
                }
  
  
                for(Employee__c emp:[Select Id, HOME_STUDY_START_DATE__c,Training_Start_Date__c,Training_End_Date__c From Employee__c Where Id In :empIds]){
                  if(pm.containsKey(emp.Id)){
                    pm.put(emp.id, emp);
                  }
              }
  
  
    for(Position_Employee__c posemp: Trigger.New){
                    If(pm.containsKey(posemp.Id)){
                  posemp.Training_Start_Date__c = pm.get(posemp.Id).Training_Start_Date__c;
                  posemp.Training_End_Date__c=pm.get(posemp.Id).Training_End_Date__c;
                  posemp.Home_Study_Start_Date__c=pm.get(posemp.Id).HOME_STUDY_START_DATE__c;}
                               }
                }
  }
  </code></pre>
  <p>I believe the issues lies in the last section but I am completely lost as to why and what the error is as the debugger isnt logging anything. I greatly appreciate any help!</p>