Write Data to 3rd Party App
Create a sample workflow to create new data in Salesforce using Events
Consider a use-case where you want to create a contact present in your system to Salesforce.
This workflow will be fired when you send an Event with the payload of the contact to be added.
In the Salesforce integration, go to Workflows
and create a new workflow by clicking on +Add Workflow
button and name it as Create New Contact
.
Building Workflow
Follow the steps given to build the workflow:
Add Trigger in Start Node
All workflows start with a trigger, which determines when the workflow will run and how data is passed into the workflow. For this workflow we will use the Event Based trigger.
Learn more about the triggers and its types here.
Click on the Start Node
, select your native app option and click on + Create New Event
.
Give a name to your event and provide all the data related to the contact in the payload.
Add Salesforce Node
Now to create a new contact in Salesforce, we need to call Salesforce API.
Click on Nodes
option in the top right and drag the Salesforce Node from Native Apps section to the workflow builder. Connect this node with Start Node.
Add Action in node
Click on Salesforce Node and add the Create Contact
action.
To provide the data in all the fields from your Event payload, just click on a field and from the Event tab under Insert Variable, select the fields from the body that you sent as payload.
Ensure that all the mandatory fields in the action are filled, else the Salesforce API will give error.
And done, you can now successfully create a contact in Salesforce whenever the event is triggered.
Refer to the Trigger Event API here to fire the event and workflow.
Test Workflow
Once your workflow is built, you can perform both node level and workflow level testing to check it.
Before testing a workflow, ensure the following pre-requisites are completed:
- Linked Account configured with authentication completed with the integration.
- Sample Payload for testing is available & configured.
Learn in depth how you can configure the pre-requisites in our Workflow Testing guide here.
Based on the type of testing that you want to perform, follow the steps below:
Testing Node
Select Node
Click on the node you want to test.
Run Node
In the node, switch to Input/Output
tab and click on Run Node
button.
Testing Entire Workflow
Open the testing modal present at the bottom.
Click on Run Workflow
button to perform a test execution and a Test Run log is generated with output of each node.
Once you are satisfied with the testing results, you can close the testing modal and move to the next steps for implementation.
Hurray!!
You have successfully created and tested a Salesforce workflow to create a new contact.