fflib-apex-common icon indicating copy to clipboard operation
fflib-apex-common copied to clipboard

Question: How to implement UOW for ContentDocumentLink?

Open lindsayholmes-gears opened this issue 5 years ago • 1 comments
trafficstars

How would one use Unit of Work to create ContentDocumentLink records? For example:

  1. Insert sObject record (registerNew)
  2. Insert ContentVersion record (registerNew)
  3. Insert ContentDocumentLink (registerNew - but with ContentVersion.ContentDocumentId)

Using registerNew(contentDocLink, ContentDocumentLink.ContentDocumentId, contentVersion) obviously doesn't work because we need the ID of the Content Document, not the Content Version. It would be nice if the library could handle these object without the need to add custom code.

However, I know there are many other high-priority issues, and for now I would be happy if anyone could provide a bit of guidance on how to implement this myself. I saw blog post comment that suggested doing this in a custom IDoWork method, but I'm not at all clear on how that could be accomplished. I couldn't find anything in the linked documentation or through online searches.

Thanks!

lindsayholmes-gears avatar Jun 04 '20 04:06 lindsayholmes-gears

@lindsayholmes-gears could one of the extensibility features of UOW such as a IDoDML or virtual methods - but used to add this behavior - it does feel quite specific to add directly.

afawcett avatar Jul 20 '20 19:07 afawcett