I have a custom search component that queries ContentVersion for files that are associated with a custom object. The query uses FirstPublishLocationId to check if a certain field is set at the record level.

The query works perfectly when a new file is uploaded to the record. The problem is that if I upload a new version of a file, it seems to wipe out the FirstPublishLocationId, which causes the file to longer return in search. Dev console confirms this, as it shows nothing in the FirstPublishLocationId column after uploading a new version.

What am I doing wrong?

FIND {canine} IN ALL FIELDS RETURNING ContentVersion(Id, ContentDocumentId, 
                                                     VersionNumber, FirstPublishLocationId, 
                                                     Title, IsLatest, ContentModifiedDate, 
                                                     FileType, Document_Type__c 
                                                     where document_type__c='Final Signed Document' 
                                                     AND FirstPublishLocationId in(SELECT Id FROM Policy__c where Policy_Stage__c='Publish'))

Your Answer

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

Browse other questions tagged or ask your own question.