• Dark Zero
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

Here is the code:

public void psiFailed()
{
Logger.info(ir, 'psiFailed() called. Inserting Case.');
Case c = new Case();
c.Type = 'Arbitration';
c.Reason = 'Undisclosed Damage';
c.Description = 'PSI FAILED: ' + ir.PSI_Review_Comments__c;
c.Inspection_Request__c = ir.Id;
c.OwnerId = UserInfo.getUserId();
c.RecordTypeId = Utils.getRecordTypeId('Case', 'Arbitration - Open');
c.VIN__c = ir.Purchase__c;
try{
insert c;
}catch(System.DmlException e){
for (Integer i = 0; i < e.getNumDml(); i++) {
if(e.getDmlType(i) == StatusCode.FIELD_CUSTOM_VALIDATION_EXCEPTION){
ir.addError(e.getDmlMessage(i));
}
}
}
Logger.flush();
Logger.flush();
}

It's being passed in the Insepction Request object (ir) and creates a new Case if the ir failed. The error occurs on line 60 which is the line "addError" is called. I checked the forms and most people mentioned the object not being in the Trigger Context when addError is called on it. However since my trigger calls this function, I do believe it's in the context. I can provide more data if needed.

Thanks,

-Eric

Here is the code:

public void psiFailed()
{
Logger.info(ir, 'psiFailed() called. Inserting Case.');
Case c = new Case();
c.Type = 'Arbitration';
c.Reason = 'Undisclosed Damage';
c.Description = 'PSI FAILED: ' + ir.PSI_Review_Comments__c;
c.Inspection_Request__c = ir.Id;
c.OwnerId = UserInfo.getUserId();
c.RecordTypeId = Utils.getRecordTypeId('Case', 'Arbitration - Open');
c.VIN__c = ir.Purchase__c;
try{
insert c;
}catch(System.DmlException e){
for (Integer i = 0; i < e.getNumDml(); i++) {
if(e.getDmlType(i) == StatusCode.FIELD_CUSTOM_VALIDATION_EXCEPTION){
ir.addError(e.getDmlMessage(i));
}
}
}
Logger.flush();
Logger.flush();
}

It's being passed in the Insepction Request object (ir) and creates a new Case if the ir failed. The error occurs on line 60 which is the line "addError" is called. I checked the forms and most people mentioned the object not being in the Trigger Context when addError is called on it. However since my trigger calls this function, I do believe it's in the context. I can provide more data if needed.

Thanks,

-Eric