2

I have written a triger (before insert) on ContentVersion object and I am checking that the user is going to upload the file in private library or public library.

According to my findings which I got from the documentation of ContentVersion object, there is PublishStatus field in ContentVersion object which determines the library(private/public). But I am not getting the exact value in the PublishStatus field.

There are three possible values for this field

  • R => file is uploaded in private library.
  • P => file is uploaded in public library.
  • U => file uploading is interrupted.

But each time in the before insert trigger I got U.

can anyone help me to identify this please? Thanks!

1

You have to populate FirstPublishLocationId, according to ContentVersion documentation:

ID of the location where the version was first published. If the version is first published into a user's personal library or My Files, the field will contain the ID of the user who owns the personal library or My Files. If the first version is published into a public library, the field will contain the ID of that library.

This field is only set the first time a version is published via the API. It isn't set when a version is published in Salesforce CRM Content or uploaded in Salesforce Files or. After the version is published, it is a read-only field.

If you don't set a FirstPublishLocationId via the API, this field defaults to the user's personal library, unless Origin is set to H, then this field defaults to My Files.

You can also reference Special Access Rules section from the link above where they have listed all requirements for the users trying to publish to public library.

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.