I want to update master detail lookup field value through trigger but i guess due to order of execution system is performing validation rule first and because of this trigger is not firing.
trigger mapCCNumber on Transaction__c (before insert) {
if(Trigger.isBefore && Trigger.isInsert) {
List<CC_Master__c> cm = [SELECT id from CC_Master__c WHERE Name = 'To be aligned' LIMIT 1];
List<CC_Reconciliation__c> ccRec = [SELECT id from CC_Reconciliation__c WHERE Name = 'To be Reconciled' LIMIT 1];
for(Transaction__c tc : Trigger.new) {
system.debug('CC Master' + cm[0].id);
system.debug('Reconcilation' + ccRec[0].id);
//CC_Number__c is master detail lookup
//CC_Reconciliation_ID__c is master detail lookup
tc.CC_Number__c = cm[0].id;
tc.CC_Reconciliation_ID__c = ccRec[0].id;
}
}
}
Is there any work around for this Thanks in advance !!