Salesforce + Highspot Integration

SoomjeetSahoo
2 min readMar 19, 2022

Hey guys, I'm back with yet another business scenario I faced while working as a salesforce developer.

Requirement:
As a Business Rep, the User needs to send the documents to Highspot (a CMS) where the User could send a Pitch to the customer.

Challenges:
1. Apex Limitations: So the first thing that came as a major hurdle is the Heap Size. Since We had to deal with large size pdfs there was no other way than to stop processing files more than 4MB(Synchronous) & 8MB(Asynchronous). Oh, wait! Heap Limits should be 6MB(Synchronous) & 12MB(Asynchronous) Right? Yes, and ill answer that in the next Challenge.

2. Request Body: Since Its a CMS and the only way you send files to any CMS is via making a Multi-Part/Form-Data type of request (To know more refer to link). Coming back to the question I ended Challenge#1 with. Creating the request body we need to encode the file in base64 and make it merge with boundaries to make a final response which increases the overall Heap. Special Thanks to Mohith Srivastava for this thread.

Solution:
Now the million dollar answer you have been waiting for, How did you solve it? Below I have broken it into points.

1.Setting up Callout: For callouts we are going to use Named Credential. Keep it in mind that you have to have an Integration user whose credentials would be used to make these callouts on behalf of user. For that, follow below steps
Login to HighSpot > On your profile icon click on Settings > Under User Settings Go For Developer Tab

User Setting Tab for HighSpot

Make Sure the integration user you will be using should have Impersonation enabled to make callouts happen. Copy and save the Key and Secret as well as the api url to hit. We will be using that in creating Named Credentials.

To Create a named credential please refer to this documentation. Yet below is how I setup

Named Credential Setup

2. Apex Implementation :
Below is Apex implementation and making callouts.

Apex Code

Please refer to the above apex code for making the file transfer via apex. FYI to handle big file size till 8MB I used the same method on Future Call.

As Always feel free to mail me if you face issues on this matter.

--

--

SoomjeetSahoo

Salesforce Dev @ Salesforce with lots of inquisitiveness to learn and grow in Salesforce and Node Domains. Currently 15x Salesforce Certified & 14x Super Badge.