This is my Before insert Trigger. When i am trying to execute this am getting error as
SObject row does not allow errors
Trigger
Trigger Service_BeforeInsert on SRV_Service__c(before insert) {
system.debug('## Inside Service_BeforeInsert ##');
if (Rfleet_TriggerAdministration.canTrigger('Service.onBeforeInsert')) {
if(trigger.isinsert && trigger.isbefore) {
Rfleet_ServiceCoachBuilderType_VFC.updateOrderCamper(trigger.new);
}
}
}
Class
public class Rfleet_ServiceCoachBuilderType_VFC {
public static void updateOrderCamper(List<SRV_Service__c> serviceLists){
String strCarSetID;
String strServiceType;
String strServiceID;
String strServiceCode;
List <SRV_Service__c> serviceRecSimpleProductCheck = new List<SRV_Service__c>();
List <SRV_Service__c> serviceList=[Select id,CarSet__c,ServiceType__c,SimpleProduct__r.Productcode__c from SRV_Service__c where id IN :serviceLists];
for(SRV_Service__c service : serviceList) {
strCarSetID= service.CarSet__c;
strServiceType=service.ServiceType__c;
strServiceID=service.ID;
strServiceCode=service.SimpleProduct__r.Productcode__c;
}
serviceRecSimpleProductCheck = [Select Id,CarSet__c,ServiceType__c,SimpleProduct__r.Productcode__c from SRV_Service__c where CarSet__c=:strCarSetID and ServiceType__c='Simple product' and ID!=:strServiceID];
for(SRV_Service__c service : serviceList) {
if (strServiceType!=null && strServiceType.equals('Simple product') && strCarSetID!=null) {
for(SRV_Service__c serviceObj : serviceRecSimpleProductCheck ) {
string str= serviceObj .SimpleProduct__r.Productcode__c;
if (str.equals(strServiceCode) ){
service .addError(Label.SRV_CoachBuilderDuplicate);
break;
}
}
}
}
}
}
serv.addError(Label.SRV_CoachBuilderDuplicate);
. POst your whole trigger hereList <SRV_Service__c> serviceList=[Select id,CarSet__c,ServiceType__c,SimpleProduct__r.Productcode__c from SRV_Service__c where id IN :serviceLists];
returning any records? As you are passing trigger.new to this method and id is not available in before insert.Can you check?