You need to sign in to do that
Don't have an account?
Controller Method array is updating 2x with try-catch
can I try and catch errors without the statement 'updates getcSelected;' actually running?
//Save and Next method
public PageReference SaveNext(){
for(Case a :getcSelected()){
a.InEditUserId__c=InEditUserId;
a.InEditUser__c=InEditUserName;
a.UserLock__c=InEditUserName + ' '+InEditTime;
a.Cancellation_Reason__c=cancelClick;
a.UserActions__c=userClick;
a.AdminActions__c=adminClick;
}
try{
Update getcSelected();
}
catch(DmlException dmle){
If(dmle.getDmlType(0) == StatusCode.FIELD_CUSTOM_VALIDATION_EXCEPTION){
ApexPages.addMessages(dmle);
return null;
}
else throw dmle;
}
Update getcSelected();
PageReference pageRef = page.BulkUpdateCases2;
pageRef.setRedirect(true);
return pageRef;
}
This solution acted as expected. I moved the final DML update statement inside the 'else' statement.
try{
Update getcSelected();
}
catch(DmlException dmle){
If(dmle.getDmlType(0) == StatusCode.FIELD_CUSTOM_VALIDATION_EXCEPTION){
ApexPages.addMessages(dmle);
return null;
}
else throw dmle;
Update getcSelected();
}