Prerequisites:
- Stambia DI Designer S19.0.18 or higher
Salesforce has a data object that stores all the files that are attached to the Salesforce records. The object is called Attachements.
You will find the description of each field of this object in the documentation below:
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_attachment.htm
You can therefore quite easily upload a file using Stambia to Salesforce, by inserting a row into this object. The file has to be inserted in base64 binary format in the field Body.
As you can see in the documentation the minimum mandatory fields that you need to map are:
ParentId - id of the parent of the parent object of the attachement
Body - base64 binary content of the attached file
Name - name of the attachement
Example:
To attach a file to Account record first you need to reverse the Attachement object.
Then you need to prepare a mapping that will insert the file.
We will use a metadata File pointing to a pdf file that we want to upload:
We will be using a "binary_content" property field to get the base64 binary content and "file_name" property field to get the name of the file.
We have to load the binary content into a binary field in a stage (note we have activated "Enable datatype" option on the stage with datatype VARBINARY as by default the field "binary_content" would be loaded as a string in the stage):
We will map the content of this field to the "Body" element of the "Attachement" Salesforce object and other fields to indicate the Id of parent record, name etc.
Executing this mapping uploads the file testing.pdf and attaches it to the record indicated by ParentID.