I have a Trigger automation that creates a mirror record when a quip document is created in salesforce. It was using hardcoded URLs and we are migrating to a different domain, so we had to change it, taking the opportunity to move it from hardcoded to manageable settings(Custom metadata in this case). This mirror record contains only basic information such as Title, Quip document link, and Document Owner. This Object is needed because even as a Quip admin and the "unredacted access" permission enabled it is not possible to have direct access to documents.

To prevent this mirror record to be created when any document is inserted it checks the FileType field on the ContentVersion for QUIPDOC.

for(ContentVersion data : lstContVersion){
    if (data.FileType == 'QUIPDOC') {

What I have tried:

  1. set PathOnclient to the same as an existing Quip file, and the filetype was set to UNKNOWN
  2. I've set the ExternalDocumentInfo1 whit a real Quip URL and also no luck.

What I knew would not work (but have tried anyways):

  • set Filetype on contentversion (Not writeable).

This is a pre-existing development from other teams that worked with the same client, and the if and its internal logic wore set on a single line, for test coverage:

for(ContentVersion data : lstContVersion){
    if (data.FileType == 'QUIPDOC') {Quip_Mirror__c quipmirror = new Quip_Mirror__c(); quipmirror .Title__c = data.Tile; /*...*/ lstQuipMirror.add(quipmirror);}

I think I would need to work with ExternalDataSources but found no good examples of how to work with it in test classes.

At this point, I'm almost returning the class to its original crap* indentation ad lack of test just o I can get this off my shoulders, but I won't be able to sleep well at night doing so. (Oh yes, I am being overdramatic here).

Thank you all for your help on this.

PS.: this also has a flow execution on the mirror object that shares the Quip doc with a group of people based on several different criteria, it uses the doc link in the mirror record to do so. I'll, probably, face a new issue related to this flow after solving this "if" problem

  • 1
    Your query for ContentVersion should be moved into a selector class ; then using dependency injection, the test method injects a mock selector that returns a list of ContentVersion sobjects (not DML'd). These can be mocked using the JSON serialize/deserialize technique to get around the field not writeable issue
    – cropredy
    Feb 9, 2023 at 18:29
  • Thanks for the help. § This is similar to an idea that I had before. § I tend to avoid mocking this kind of thinking because if not done properly it can interfere with different tests in the org, related to the same object, but looks like this is the only option Feb 10, 2023 at 9:07
  • dependency injection can be done on a testmethod-by-testmethod basis; when coupled with the UnitofWork pattern, you can even dependency inject the DML updates done by the code-under-test
    – cropredy
    Feb 10, 2023 at 18:33

1 Answer 1


A colleague and I were working on this (via data migration, not apex) and guessed our way into a solution. For some reason, when Quip doc ContentVersion records are created in the standard way, there is a secret handshake and the PathOnClient attribute does not include a file extension, but FileType populates fine.

The solution: add ".quipdoc" to the original PathOnClient.

So strange. Again, this worked in a data load context, so I cannot be sure about apex.

Now, we are trying to figure out what to do to get FileType = "QUIPCHAT"...

As for the design pattern approach, it looks like you have more help there. 😀

  • I am working on a different subject related to ContentDocument/Links, I'll try this when updating the test class, thanks for the tip Jun 8, 2023 at 11:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .