1

Is there any way to use the fflib uow pattern to insert attachments and relate it to a parent sObject (in this case to an Event)? I am facing the following error due to the parentId is not an SObjectField.

    Attachment attachment = new Attachment();
    attachment.name = 'myName';
    attachment.ContentType = 'plainText';
    attachment.Body = Blob.valueOf('Text');
    uow.registerNew(attachment,Attachment.ParentId,EventSF);

Error:

Error:(414, 13) Method does not exist or incorrect signature: void registerNew(Attachment, Id, Event) from the type fflib_ISObjectUnitOfWork

2

You just shadowed the name of the standard object (Attachment) with your instance of it (attachment). Either rename it:

Attachment record = new Attachment();
SObjectField parentIdField = Attachment.ParentId;

Or if you don't want to change the name of your record instance, you need to use the fully qualified name to disambiguate:

Attachment attachment = new Attachment();
SObjectField parentIdField = Schema.Attachment.ParentId;
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.