2010年7月13日火曜日

try..catch

try{
insert myObj;
}catch (DmlException e){
System.assertEquals('FIELD_CUSTOM_VALIDATION_EXCEPTION',e.getDmlStatusCode(0));
}

対象データ削除

List delObj= [select id from MyObj__c where createdById = :createdbyId];
if(!delObj.isEmpty()){
delete delObj;
}