Advanced: Generating the External Sharing URL using Apex

This article contains information on advanced customization for Salesforce developers to generate and store the External Sharing URL in a Custom Field using Apex.

Use Case: Including the External Sharing URL in Email Templates or passing the URL to an external system.

Generating the URL manually

Taskfeed’s External Sharing URL has been designed to be secure while frictionless for customers to view the plan and its progress in real time.

  • A board can only be shared when the Sharing Settings for that particular board are set to Public.

  • The URL is only generated after a user selects the Share button on that board for the first time.

However, it might be useful in some cases to create the URL on-demand to include it in an Email Template, for instance, or pass the URL to an external system.

Generating the External Sharing URL using Apex

We expose the mechanism to generate the URL to an Apex API. This method allows your developers to create the URL on-demand and store the result in a custom field.

When generating the URL, a unique token is created for the Board and the person who generated the URL. This token means the URL is too long for Salesforce’s URL field.

You will need to create a custom Long Text Area field with the length of 500.

This is a code sample to generate the URL when the Board is set for External Sharing:

trigger BoardExternalSharingURLTrigger on taskfeed1__Board__c (after insert, after update) {

   List<taskfeed1__Board__c> boardsWithURL = new List<taskfeed1__Board__c>();

   for (taskfeed1__Board__c board : Trigger.New) {

       if (board.taskfeed1__External_Sharing__c == 'Public' && board.External_Sharing_URL__c == null) {

           taskfeed1__Board__c boardWithURL = new taskfeed1__Board__c(Id = board.Id);

           boardWithURL.External_Sharing_URL__c = taskfeed1.TaskfeedApexAPI.getBoardGuestAccessURL(board.Id);

           boardsWithURL.add(boardWithURL);

       }

   }

   update boardsWithURL;

}

Feedback and Knowledge Base