You need to sign in to do that
Don't have an account?

Need help for FIELD_CUSTOM_VALIDATION_EXCEPTION
Hi Team,
When we are running the below batch apex we are facing the erros like "FIELD_CUSTOM_VALIDATION_EXCEPTION, When the Customer Connect Request Status is Pending or Approved, the Account Name and Address cannot be edited ".Actually there is a validation rules are firing.How we can avoid the validation rules using my code?Please find my below code which we are trying and help us to avoiding the errors.
Apex Class:
global class OpportunityDays implements Database.Batchable<Sobject>{
global OpportunityCWDays(){
}
global Database.QueryLocator start(Database.BatchableContext BC){
String query = 'Select id, StageName, Software_Product_Count__c, CW_in_Last_30_Days_Formula__c, CW_in_Last_30_Days_Workflow__c, CW_in_Last_730_Days_Formula__c, CW_in_Last_730_Days_Workflow__c from Opportunity Where Software_Product_Count__c > 0 AND StageName = \'S8- Closed Won\'
;
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC,List<Opportunity> lstOpp){
for(Opportunity objOpp : lstOpp){
if(objOpp.CW_in_Last_30_Days_Formula__c && !objOpp.CW_in_Last_30_Days_Workflow__c) {
objOpp.CW_in_Last_30_Days_Workflow__c = TRUE;
}
else if(!objOpp.CW_in_Last_30_Days_Formula__c && objOpp.CW_in_Last_30_Days_Formula__c ) {
objOpp.CW_in_Last_30_Days_Workflow__c = False;
}
if(objOpp.CW_in_Last_730_Days_Formula__c && !objOpp.CW_in_Last_730_Days_Workflow__c) {
objOpp.CW_in_Last_730_Days_Workflow__c = True;
}
else if (!objOpp.CW_in_Last_730_Days_Formula__c && !objOpp.CW_in_Last_730_Days_Workflow__c){
objOpp.CW_in_Last_730_Days_Workflow__c = False;
}
}
update lstOpp;
}
global void finish(Database.BatchableContext BC){
}
}
Thanks
When we are running the below batch apex we are facing the erros like "FIELD_CUSTOM_VALIDATION_EXCEPTION, When the Customer Connect Request Status is Pending or Approved, the Account Name and Address cannot be edited ".Actually there is a validation rules are firing.How we can avoid the validation rules using my code?Please find my below code which we are trying and help us to avoiding the errors.
Apex Class:
global class OpportunityDays implements Database.Batchable<Sobject>{
global OpportunityCWDays(){
}
global Database.QueryLocator start(Database.BatchableContext BC){
String query = 'Select id, StageName, Software_Product_Count__c, CW_in_Last_30_Days_Formula__c, CW_in_Last_30_Days_Workflow__c, CW_in_Last_730_Days_Formula__c, CW_in_Last_730_Days_Workflow__c from Opportunity Where Software_Product_Count__c > 0 AND StageName = \'S8- Closed Won\'
;
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC,List<Opportunity> lstOpp){
for(Opportunity objOpp : lstOpp){
if(objOpp.CW_in_Last_30_Days_Formula__c && !objOpp.CW_in_Last_30_Days_Workflow__c) {
objOpp.CW_in_Last_30_Days_Workflow__c = TRUE;
}
else if(!objOpp.CW_in_Last_30_Days_Formula__c && objOpp.CW_in_Last_30_Days_Formula__c ) {
objOpp.CW_in_Last_30_Days_Workflow__c = False;
}
if(objOpp.CW_in_Last_730_Days_Formula__c && !objOpp.CW_in_Last_730_Days_Workflow__c) {
objOpp.CW_in_Last_730_Days_Workflow__c = True;
}
else if (!objOpp.CW_in_Last_730_Days_Formula__c && !objOpp.CW_in_Last_730_Days_Workflow__c){
objOpp.CW_in_Last_730_Days_Workflow__c = False;
}
}
update lstOpp;
}
global void finish(Database.BatchableContext BC){
}
}
Thanks
Any triggers on opportunity.Check once.
Thanks.