You need to sign in to do that
Don't have an account?
Is there a constraint on using DML in non-void methods?
My trigger requires a bit complex processing so I wanted to break down logic by creating methods in a Utility class
One of the methods create a detail record, so I declared ıt as type boolean to return status:
public with sharing class Utility_MaintainTransferRequests {
public static boolean CreateNewDealer (Case inTRRequest) {
...... control logic
...... create record
try {
insert nwDealer;
}
catch(Exception e){
inTRRequest.adderror('Y...........!!!!');
return false;
}
But get an error as :
Save error: Non-void method might not return a value or might have statement after a return statement. Utility_MaintainTransferRequests.cls
Does it mean I cant use DML in non-void methods or is there sthg wrong with code?
Thanks
You need to set a return value outside the try catch block or set a return value within the try as well as the catch sections. As it currently stands, you only return a value IF the DML fails, if it passes you do not return anything.
All Answers
You need to set a return value outside the try catch block or set a return value within the try as well as the catch sections. As it currently stands, you only return a value IF the DML fails, if it passes you do not return anything.
You are right, thank u...
Wont post questions after 12 hrs of work again :)