I get this error 7 times for 7 different classes.
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, trgr_DocoSilentMode: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.trgr_DocoSilentMode: line 7, column 1: [] Stack Trace: Class.Test_siteEventOriginizer.site_eventContactDetailsTest: line 160, column 1
This is the trigger code. What is the issue? Thanks.
trigger trgr_DocoSilentMode on Project__c (after update)
{
List<Project__c> opNew;
Map<ID,Project__c> opOld;
for(Project__c prj : opNew)
{
Project__c oldPrj = opOld.get(prj.id);
if(prj.forms__c != oldPrj.forms__c)
{
System.debug('DOCO IN');
//First remove all current attachments
removeCurrentAttachments(prj.id);
String docFormat = prj.forms__c;
//Send Multi Pickist values to generateDocument method
if(generateDocument(prj.Id, docFormat))
{
}
// final
prj.forms__c = null;
}
}
public void removeCurrentAttachments (String prjID)
{
// Remove all current attachments on the document
List<Attachment> allAttachments = [Select ID, ParentID, body, Name from Attachment Where ParentID = :prjID AND Name LIKE '%Jafi - Education Office%'];
// Only attempt to delete attachments if there is at least one
if(allAttachments<> Null) delete allAttachments;
}
public Boolean generateDocument (String prjID, String docFormat)
{
// System.debug('DOCO: ' + 'prj: ' + prjID + ', docFormat: ' + docFormat);
// This method generates the docomotion documents as per the parameters that are passed to it
try{
if(docFormat != Null && docFormat.contains('Education Office'))
{
doco.RenderAPI.renderCreateFileAsync(4, prjID, doco.RenderAPI.Mode.Attachment, doco.RenderAPI.Format.Docx,'Jafi - Education Office ' + datetime.now() );
}
}
catch (Exception e)
{
System.debug('DOCO ERROR:' + e);
}
return True;
}
}