I have 2 custom objects
- Timecard (pse__Timecard_Header__c)
- Period (c2g__codaPeriod__c).
They don't have relationship.
Timecard fields:- Start date (pse__Start_Date__c), Close date (pse__CloseDate__c), Project (pse__Proj__c). Now here, inside project is one field Region (pse__Region__c).
Period fields:- Start date (c2g__StartDate__c), Close date (c2g__Closed__c), Region (c2g__Region__c ), status (checkbox).
If the status is checked and start date, close date and region are matching with the start date, close date and region of Timecard object then I want Timecard to be rejected.
I started with the following code but then get lost realising I don't have direct access to region inside project.
trigger TimecardRejection on pse__Timecard_Header__c (before update) {
List <Object> tcdata = new List <Object> ();
for(pse__Timecard_Header__c tc: Trigger.new){
Date startDate = tc.pse__Start_Date__c;
Date endDate = tc.pse__End_Date__c;
tcdata.add(tc);
}
}
Any help would be appreciated. Thanks in advance.