Doing bulk within a formula can be a little difficult. Bulk by nature is an asynchronous job, while formulas are a synchronous procedure. One way to get them to work together is via webhooks.
There are two ways to know when a bulk job is completed. You can poll the GET /bulk/{id}/status
endpoint repeatedly until status is COMPLETED
or ABORTED
or you can set the header Elements-Async-Callback-Url
and receive a webhook when the job is done.
When using webhooks, the key is to have two formulas. One to start the bulk job and set the Elements-Async-Callback-Url
to manually trigger a second formula that downloads the results and sends them somewhere else.
Here are two example formulas when using the webhook method. They will bulk download from one instance, and bulk upload to another.
IMPORTANT NOTE: for these formulas to work, you must use a common resource! You must be able to call GET /MyResource
, copy a payload that gets returned and call POST /myResource
to the other endpoint. I will include my example transformations.
To Configure:
- Import both formulas Bulk Step 1.json and Bulk Step 2.json.
- Create the common resource by calling
POST /organizations/objects/MyContact/definitions
with this payload: ObjectDefinition.json - Create transformations for Salesforce by calling
POST /organizations/elements/sfdc/transformations/MyContact
with: MyContactSFDC.json - Create transformations for DynamicsCRM by calling
POST /organizations/elements/dynamicscrm/transformations/MyContact
with: dynamicscrmMyContact.json - Create a formula instance for Bulk Step 2 and capture the ID of the created formula instance.
You will need to give the Bulk Step 1 formula the instance ID for the second formula. This will let the webhook trigger the correct formula instance
- Create a formula instance for Bulk Step 1 using the formula instance id from step 5.