You need to sign in to do that
Don't have an account?
Simon Baird
Invalid id value for this SObject type - Trigger on attachment
Hi all,
I need some help with a trigger that attaches the date time to a field when an attachment is added to a custom object (patient__c). The trigger works fine when attaching a file to the patient record but when you try and attach a file to any other object it throws the error "Invalid id value for this SObject type"
Below is the trigger
trigger LastAttach on Attachment (After insert) {
list<patient__c> ptlist= new list<patient__c>() ;
Patient__c ac= new Patient__c();
for (attachment a : trigger.new ){
ptlist.add( new Patient__c(Id=a.ParentID, Attachment_Added__c= System.now()));
}
//}
update ptlist;
}
I need some help with a trigger that attaches the date time to a field when an attachment is added to a custom object (patient__c). The trigger works fine when attaching a file to the patient record but when you try and attach a file to any other object it throws the error "Invalid id value for this SObject type"
Below is the trigger
trigger LastAttach on Attachment (After insert) {
list<patient__c> ptlist= new list<patient__c>() ;
Patient__c ac= new Patient__c();
for (attachment a : trigger.new ){
ptlist.add( new Patient__c(Id=a.ParentID, Attachment_Added__c= System.now()));
}
//}
update ptlist;
}
All Answers
I'm Shingo.
You need to check if the type of ID is expected custom object.
So, how about this?