documentation logo
All you’ll ever need to know about Declarative Webhooks and how to get started.

Pages

Step 3: Inbound Template Actions

Response Actions Section

Here you will define actions based on the received call. We have provided you with a guide on how to use these options.

Find/Update Main Record: This is a type of action you can only add once per template. You have the option to identify the main record to be used in this call by matching a field from the Salesforce object with a received body node value. This record can be updated or created if not found. If you select any of the create/update actions, you will be able to map further fields from your inbound call body. Furthermore, the main record found (or created) can be used in the next actions.

Create Record: Here you have the option to create a new record, related or unrelated to the main record identified above.. You can select the object type you want to create and choose how it’s related to the main object.

Update Related Record: This option enables you to update a record related to the main record identified above. For example, if Contact was your main object, you can use this to update the Account that the object is related to after the inbound call is made. Similar to the previous options, you have the ability to map fields associated with your related record here.

Upsert Single Record: This option enables you to update a record that can be identified by matching a Salesforce field with a node value. If no record is found, then you have the option to create it.

Upsert List of Records: This option enables you to update a list of records based on a list from the JSON request. Each record can be identified by matching a Salesforce field with a node value. If no record is found for each list item, then you have the option to create it.

Create / Update File: This option enables you to create or update a Salesforce Attachment or File (ContentDocument) based on the JSON request. Each file can be identified by matching a Salesforce field with a node value. If no record is found for each list item, then you have the option to create it.

Run Autolaunched Flow: This feature allows you to utilize the capabilities of an “Autolaunched Flow (No Trigger)” to perform complex calculations and logic beyond basic record insertions and updates.

Run Apex: This option enables you to run an apex class as an inbound action.

 

Find/Update Main Record

Let’s say in this example we want to update an Account record. As we have a Node for account ‘id’ we can use this in our action mapping to identify the account record we want to update. In the dropdown you can select which Salesforce field to search by and which URL parameter or request body node to use as a value.

You can add an additional line with Field – Node matching criteria by clicking “+”. If you add a second one, it’s used as a backup match to identify a record. If the first match doesn’t find anything, the second match will be attempted.

Now that we have mapped WHAT account we want to update (via Account Name) our next step is to check ‘Update main record: Account’ to true so we can map what fields we would like to update on the account record:

Select the ‘Add Field’ button to map fields to update on your account record. In the Source dropdown you have the following options:

  • If you choose Static Value, the field will be updated with that exact provided value every time the callout is made. You can provide the specific value in the “Value” field. This is useful if you want to set a status or a flag on the record.
  • Selecting Request Body Node will allow you to update the field with a value from the Request Body:
    • Click on the Edit icon at the right of the Value input to select a request body node to use to map into the field
    • If you encounter a list, you also have the option to add a filter on that list BEFORE clicking on “Select Node”. If you set the filter and it’s part of the JSON path, the filter will be included in the selected path and will be applied when the node is saved in the field.
  • Formula: This allows you to build a formula using values from the request body.
    • Click the Edit icon to edit the formula. See more details in the “Using Formulas” section of this user guide.
  • Custom Metadata: Custom Metadata: This allows you to map a field from a Custom Metadata Type record into the record field.
    • Click on the Edit icon to select a custom metadata value
  • Custom Setting: This allows you to map a field from a Hierarchy or List Custom Setting record.
    • Click on the Edit icon to select a custom setting value
  • If you choose URL Parameter, you will be able to enter the incoming URL parameter to use to map into the field.
  • Identify Record by External Id: When updating a field that is a lookup, you have the option to associate it with a record using an external ID field. By selecting this option, you can choose a field from the object being looked up to and a node from the request body. During the call, the template will attempt to find the record for the lookup by matching the specified field with the value from the corresponding node in the request body.

 

Create Record

Here you have the option to create a new record, related or unrelated to the main record identified above.. You can select the object type you want to create and choose how it’s related to the main object.  To create a new record, select the Add New ‘Create Record’ Action.

Choose your Object Type. Because we have identified the main record in the previous step, you can select how to relate this new record to the main record.

Further, if you select ‘Add Field,’ you can map additional fields in your record creation. You can choose to set static values to a field, map from a request body node or from an incoming URL parameter.

 

Update Related Record

Similar to our previous examples, this option allows you to update a record related to your main object. For example, if you wanted to update the parent account record related to the main Account record.

 

Upsert Single Record

This option enables you to update a record that can be identified by matching a Salesforce field with a node value. If no record is found, then you have the option to create it.

If you select a value in the “Related to the main object through” input, only the records related to the main record are identified, and if a record needs to be created, it will be linked to the main record.

Just like the other actions, you can map fields from the JSON request or static values. Additionally, you can use the “Only on insert” or “Only on update” toggles to limit some of the mapping to the create or update action only.

 

Upsert List of Records

This option enables you to update a list of records based on a list from the JSON request. Each record can be identified by matching a Salesforce field with a node value. If no record is found for each list item, then you have the option to create it.

If you select a value in the “Related to the main object through” input, only the records related to the main record are identified, and if a record needs to be created, it will be linked to the main record.

You need to select a JSON list from the request by clicking on “Select” next to “Created based on this JSON List”. After selecting a JSON list, choose how to identify each record by selecting a Salesforce field and a JSON node from inside the JSON list.

Just like the other actions, you can map fields from the JSON request, URL parameters or set from static values. Additionally, you can use the “Only on insert” or “Only on update” toggles to limit some of the mapping to the create or update action only.

 

Create / Update File

This option enables you to create or update an Attachment or a File (ContentDocument) based on the request.

First, you need to select what type of record you want to create: File (ContentDocument) or Attachment. After selecting, you will be able to choose the field and node used to identify an existing record to update, in case you want to update an existing file or attachment.

Then you can map fields from the JSON request or static values. Additionally, you can use the “Only on insert” or “Only on update” toggles to limit some of the mapping to the create or update action only.

 

Run Autolaunched Flow

This feature allows you to utilize the capabilities of an “Autolaunched Flow (No Trigger)” to perform complex calculations and logic beyond basic record insertions and updates.

The process begins by selecting a flow. If the flow requires input variables, a list will be displayed for mapping. These inputs can be either the main record ID, a URL parameter or individual values from the request body. When the inbound call takes place, the flow will be executed using the mapped input values.

Only active Autolaunched flows without trigger can be selected.

Run Apex

This option allows you to run an apex class when the inbound call is received.

 

The class you enter needs to be a global class that extends the d_wh.InboundActionCallable2 abstract class and implements the d_wh.InboundActionCallable2.CallResponse Run(Map<String, String> parameters, Map<String, String> headers, String requestBody) method.

Below is an example class that can be used as a “Run Apex” inbound action.

global class TestCallable extends d_wh.InboundActionCallable2 {

    global override d_wh.InboundActionCallable2.CallResponse Run(Map<String, String> parameters, Map<String, String> headers, String requestBody) {

        // Add code to handle inbound call
        return null;
    }

}

The parameters parameter contains the URL parameters received by the inbound call.

The headers parameter contains the headers received by the inbound call.

The requestBody parameter contains the received body as string.

The d_wh.InboundActionCallable2.CallResponse return object is reserved for future use. Return null for now.

 

Call Action Criteria

For each call action, you have the option to select if the action will run. By default, the actions will always run. You can customize that by scrolling down to the “This action runs if” input and click on it. That will open a popup where you can refine the creitria.

 

You can specify custom criteria based on header values, URL parameters, as well as the request body items.

 

Additionally, the action can be skipped if the main action “Find/Update a Main Record” failed to identify or create a record. You can set that by checking the “Skip this action if a main record was not found or created” checkbox.

NOTE: You can change the order of your actions by clicking on the arrows to the right of each action. The actions will run in the order you have defined them.

 

Additional considerations

If you are mapping values into Date or DateTime fields, the received value needs to be in the standard yyyy-MM-dd format for Date fields or yyyy-MM-ddTHH:mm:ss.sssZ format for DateTime fields.