function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Naresh AVNaresh AV 

Access “Share via link” properties (and link) using apex

Hi All,
I have an attachment with "Anyone with link" sharing configuration. How can I retrieve (or construct) the actual sharing URL using the apex code?
E.g., I have an attachment with id: 069240000009bdU and ViewAll permissionsI. From UI (web) I can see that its URL is:
How can I get this URL through Apexcode and update to custom field?

Thanks in Advance.
Hi Naresh,

This link is stored in an object called "ContentDistribution".

You can use below query to get this information.

Select Id, DistributionPublicUrl  FROM ContentDistribution WHERE ContentDocumentId = '069240000009bdU'.

If this resolves your issue, please mark it as solved.