In this process flow we are going to walk you through the steps of uploading documents in Salesforce.
As an example, the process flow picks up a file from a source folder, encodes the file into Base64 binary and uploads the file into a specific folder or record in Salesforce. Process Flow uses the Salesforce SOAP API and executes the Create function on Document or Attachment object types.
Document object uploads documents to a folder. Attachment object attaches documents to a specific record.
The high-level steps to configure the solution are:
Here are the two process flows that are used in the setup of the File Upload to Salesforce solution.
In the above sub-process, we are calling the Salesforce Login and passing the username, password appended with security token. The sub-process can be reused as a common template for additional Salesforce SOAP operations.
The response from the SOAP call contains serverUrl and sessionId that we are setting as set-parent-context via a custom plugin. This plugin sets the two variables and their values into the parent flow.
Here’s the parent flow that calls the Login sub-process and receives the sessionId and serverUrl, calls the Create function and passes the Create Document request (built via mapping) to the Salesforce web service call. As part of this process we are also setting the Header which needs to be passed to the SOAP service call.
One of the key step in the process flow is the Create Document mapping activity. There are few important mapping rules that we need to note so that the document is uploaded correctly in a particular folder in Salesforce.
Here the function we are using is the Base64 Binary Encoder function available in the Adeptia data mapping tool. In this function, you can pass the file name along with the file path or pass a context variable that contains the file location or data that needs to be encoded dynamically.
Additional fields that are required are Folder ID and Name of the file. Apply filter-unmapped elements on the rest of the fields. To get the Folder ID, you can create another simple flow in Adeptia that pulls the list of all the folders in your Salesforce account. You can take the Folder Id and pass this value in the mapping.
Name of the file is required. This would be the document name that would be shown in the folder. Also note that the folder in Salesforce must have read/write permissions.
Here's a snapshot of the document uploaded to a folder in Salesforce through this solution.
Here's a snapshot of a document attached to a record through this solution.
We have attached the process flows that are needed to upload documents in Salesforce. Please use the migration utility to migrate the flows into your local Adeptia instance.