Automate Salesforce File Sharing as Public Link with Chatter REST API

nialljpmurphy
2 min readOct 15, 2018

--

In certain use cases you may have a need to share files on a record or group with people outside your organisation. E.g. You’re working on a project with stakeholders outside your organisation.

Here is a Chatter Rest API which allows 1 link per a file

and an SObject API which allows multiple, as well as setting other options.

Our Lightning UI uses the Connect API, but if you do something custom, you’d probably want to use SObject.

You can trigger on many files actions, such as upload to create such links.

Chatter REST API Example

Use Case: File attached to a record and we want to share it as we do with the Public Link Sharing via UI. Chatter REST API PUT action to /services/data/v43.0/connect/files/<FileID>/file-shares/link with this body

{
"sharingType" : "V"
}

here the API message response containing the URL for the file thats shared:

{
"fileViewUrl" : "https://xxxxdomain.my.salesforce.com/sfc/p/1H000000NiOk/a/1H000000Xgo9/d1mg90l6hgr87uJ2TAPZBV2sn7tleCLPp5eKJThXf8s", "sharingType" : "V"
}

and here other options but for the public share the V sounds good enough

Of course another option here is to use a community portal to securely share the file(s) with a group of users but sharing this lightweight approach in case it is useful for others.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

nialljpmurphy
nialljpmurphy

Written by nialljpmurphy

Solution Engineering Leader. Building teams and products that help organisations connect with each other and their customers. CRM, Commerce, Portals etc.

No responses yet

Write a response