Skip to main content
1 of 8

APEX trigger lookup field value in onther custom object

today I signed in on SF Stackexchange and I'm a newbie on Apex. My User story: Uptill know we used an MS Access application for complaint registration/handling. Because we want to get rid of MS Access applications I created an object in SF called Complaints__c. Creating a task for the complaint handler, sending him/her an email that a complaint is assigned to him/her and logging that email on the activity timeline works great. Last thing I want to do is auto fill the deadline. When a new complaint is registered, the complaint handler has to do a follow up before the Deadline that is set when de complaint is registerd. The Deadline can depend on 2 values in another field, let's say Option: option 1, Option 2 If Option 1 is chosen, the Deadline is different then when option 2 was chosen. I have a second Custom object Called PeriodOfTime__c that contains Id, Name, Date__c, Option1Date__c, Option2Date__c. On registration I would like use an apex trigger to fill (before insert) the field Deadline__c in my Complaints__c object with the value of Option1Date__c or Option2Date__c from the Object PeriodOfTime__c where PeriodOfTime__c.Date__c = date.today() I stored these dates in this table to make sure that Option1Date__c and Option2Date__c are never a saterday, sun