In this tutorial, learn how to automate the creation of accounts and orders in Priority when an Opportunity is Closed Won in Salesforce.
Prerequisites #
Before you begin, ensure the following connections are established:
- Connection between Engini and Priority.
Learn how to connect priority to Engini - Connection between Engini and Salesforce.
Learn how to connect Salesforce to Engini
Add Outbound Message Webhook #
To get started, add a trigger:
- Add a new activity and choose “Outbound Message Webhook” trigger of Salesforce.
- Click on the “to JSON\XML sample” button to paste sample JSON payload.
- example for a JSON payload:
{ "?xml": { "@version": "1.0", "@encoding": "UTF-8" }, "soapenv:Envelope": { "@xmlns:soapenv": "http://schemas.xmlsoap.org/soap/envelope/", "@xmlns:xsd": "http://www.w3.org/2001/XMLSchema", "@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", "soapenv:Body": { "notifications": { "@xmlns": "http://soap.sforce.com/2005/09/outbound", "OrganizationId": "00DA0000000aP3dMAE", "ActionId": "04k2I000000blT9QAI", "SessionId": "00DA0000000aP3d!AQEAQLPsw0SS1JU4GXki74NqiLNDGAxwaMK2xyMBAPeIb8u4SerIBcbji9VcIX5HDIVkd.0cmMQQY7.0WdMyP8R93s8pJclC", "EnterpriseUrl": "https://engini-dev.my.salesforce.com/services/Soap/c/58.0/00DA0000000aP3d", "PartnerUrl": "https://engini-dev.my.salesforce.com/services/Soap/u/58.0/00DA0000000aP3d", "Notification": { "Id": "04lJw000003VYlFRQW", "sObject": { "@xsi:type": "sf:account", "@xmlns:sf": "urn:sobject.enterprise.soap.sforce.com", "sf:Id": "a0IJw000000kIJ9MAM" } } } } } }
- example for a JSON payload:
- Click on the copy icon on the right side of the URL to copy the URL.
- Set up an Outbound Message in salesforce with the copied URL.
- Set up an Flow in Salesforce with the outbound message:
- Back in Engini, click on the “next step” button.
Get Opportunity #
Next, add the “Get Opportunity” action of salesforce to get all details of the opportunity:
- Object Type
Choose from the drop down the opportunity option. - Record ID
- Click on the empty field, and the tooltip will pop up showing the options of the values you can choose.
- Choose the “sd:id” value, by following the path:
response body -> soapenv:Envelope -> notifications -> Notification -> Sobject -> sf:id
Get Opportunity Products #
Next, add the “Get Opportunity Producs” action of salesforce to get all products of the opportunity:
- Object Type
Choose from the drop down the opportunity product option. - Filter
- Click on the “Add filter” button.
- On the left field, select from the drop down the field you want to add the filter on. For this process choose the “Opportunity ID” field.
- On the middle field, choose from the drop down the “=” condition.
- Click on the right field, and the tooltip will pop up showing the options of the value you can choose:
- Choose the “Opportunity ID” value, from the previous activity of “Get Opportunity”.
- Choose the “Opportunity ID” value, from the previous activity of “Get Opportunity”.
Get Account #
Next, add the “Get Account” action of salesforce to the account:
- Object Type
Choose from the drop down the account option. - Record ID
- Click on the empty field, and the tooltip will pop up showing the options of the values you can choose.
- Choose the “Account ID” from the “Get Opportunity” activity.
Initialize Variable #
Now, let’s initialize a variable that will later hold the customer number of the customer in Priority:
- Choose “Initialize Variable” action of Engini.
- Name field
Click on the empty field and choose from the tooltip a name for the variable. For example “customer number” - Type field
Choose from the drop down the “string” option. - Click on the “next step” button.
Add If Condition #
Add the “If Condition” action of Engini:
- Click on “Add conditions” button.
- Click on left the field to show the tooltip with all the options you can choose:
- Click on the functions label
- Choose the “StringIsNullOrEmpty” function, which checks whether a given string is empty or null.
- Choose the “account number” value from “Get Account” activity as an input.
- Select the equals (=) condition.
- Click on the right field and write ‘True’
- If Yes
If the condition is met, the workflow will turn to execute the process within the if yes block.- Click on “Next step” button to add a activity that will be carried out if the condition is met.
- Add “Create “לקוחות”” activity. follow the steps.
- Add “Form Activation” activity. follow the steps.
- Add “Get Items “לקוחות” activity. follow the steps.
- Add “Update Record” activity. follow the steps.
- Add “Set Variable” activity. follow the steps.
- If No
If the condition isn’t met, the workflow will turn to execute the process within the if no block.- Click on “Next step” button to add a activity that will be carried out if the condition is not met.
- Add “Set Variable” activity. follow the steps.
Create “לקוחות” #
- Add a new activity and choose “Create “לקוחות”” action of priority.
- Click on the “Add fields” button to fill the fields in the “לקוחות” form.
- On the left field, select from the drop down the field you want to populate in the table. For this process choose the “שם לקוח” field.
- Click on the right field, and the tooltip will pop up showing the options of the values you can choose. For the “שם לקוח” field choose the “account name” value from the get account activity.
Form Activation #
When creating a customer in Priority, it is initially set up as a temporary customer by default. To activate the customer and transition them to an active status, we utilize Priority’s activation form.
- Add the “Form Activation” activity of Priority.
- Choose the “לקוחות” Form name from the drop down menu.
- Choose the “הפיכת לקוח זמני ללקוח”Activation from the drop down menu.
- Click on the empty field and choose from the tool tip the number of the customer from the “Create “לקוחות”” activity.
For more information about the Form Activation see the Priority guide.
Get Items “לקוחות” #
After activating the customer, we need to retrieve their information using their customer name because a new customer number has been assigned.
- Add a new activity and choose “Get Items “לקוחות” activity of Priority.
- Filter
- Click on the “Add filter” button to fill the fields in the “לקוחות” form.
- On the left field, select from the drop down the field you want to add the filter on. For this process choose the “שם לקוח” field.
- On the middle field, choose from the drop down the “=” condition.
- Click on the right field, and the tooltip will pop up showing the options of the value you can choos
- Choose the “שם לקוח” value, from the previous activity of “Create “לקוחות””.
- Top N
We will specify to retrieve only one record.
Update Record #
- Add a new activity and choose “Update Record” action of Salesforce.
- Object Type
Choose from the drop down the account option. - Record ID
- Click on the empty field, and the tooltip will pop up showing the options of the values you can choose.
- Choose the “Account ID” from the “Get Opportunity” activity.
- Click on the “Add fields” button.
- On the left field, select from the drop down the field you want to populate in the table. For this process choose the “account number” field.
- Click on the right field, and the tooltip will pop up showing the options of the values you can choose. For the “account number” field choose the “מס.לקוח” value, from the previous activity of “Get Customer”.
- Click on the “next step” button.
Set Variable #
- Choose “Set Variable” action of Engini.
- Click on the drop down and choose the name you gave the variable you initialize.
- Click on the empty field next to the “value” and choose from the tool tip the number of the customer from the “Create “לקוחות”” activity.
- Click on the “next step” button.
Create “הזמנות לקוח” #
Add a new activity and choose the “Create “הזמנת לקוח”” action of Priority:
- Click on the “Add fields” button to fill the fields in the “הזמנות לקוח” form.
- On the left field, select from the drop down the field you want to populate in the form.
For this process choose the field “מס.לקוח” - Click on the right field, and the tooltip will pop up showing the options of the values you can choose. For the “מס.לקוח” field choose the variable you initialize few activities before.
- Repeat on steps 1-3 to Add more fields in addition to the fields we already added, if necessary.
Update Record #
After creating the new customer orders in Priority, we need to update the corresponding Opportunity record in Salesforce with the “priority order number” for future reference.
- Add a new activity and choose “Update Record” action of Salesforce.
- Object Type
Choose from the drop down the opportunity option. - Record ID
- Click on the empty field, and the tooltip will pop up showing the options of the values you can choose.
- Choose the “sd:id” value, by following the path:
response body -> soapenv:Envelope -> notifications -> Notification -> Sobject -> sf:id
- Click on the “Add fields” button.
- On the left field, select from the drop down the field you want to populate in the table. For this process choose the “priority order number” field.
- Click on the right field, and the tooltip will pop up showing the options of the values you can choose. For the “priority order number” field choose the “הזמנה” value, from the previous activity of “Create “הזמנות לקוח””.