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

Pages

Step 3: Callout Template Request Body (Form-Encoded Format)

Request Body Page (Form Encoded Body Builder)

If you selected “Form Encoded” in the first step of the wizard for “Request Body Format”, the 3rd step will let you build the form encoded POST string.

The Form-Encoded body is composed of name-value pairs in the format name1=value1&name2=value2…

In order to define new body elements, click on the ‘Add’ icon. A new popup will be displayed, where you can add the details of the form element:

If you select the Node Type as “Single Value“, you can specify what value to use in the “Value Source” input:

  1. Static value: You can set a static value to be sent to the server for the selected name. Simply select “Static” for Value Source, then add your static value below.
  2. Field mapping: This option allows you to map a field from the selected main object or any related record. Select “Field” for Value Source. The Field Selector allows you to select fields from the Main Object, any related object (up to 5 levels deep) and any related list (one level). For example, if the Main Object is Account, the selection below allows you to select the Username of the Owner of the Account.
    • If the selected field is a Blob field (for example Attachment -> Body or ContentVersion -> VersionData), then you will also be asked to provide the encoding to be used: Base64, Hex or Raw (which only works for UTF-8 content)
  3. Formula: This option allows you to build a formula using the current object’s fields that will be used to generate the node. See more details in the “Using Formulas” section of this user guide.
    • Clicking the Edit icon will open the Formula editor. See more details in the “Using Formulas” section of this user guide.
  4. Custom Metadata: This allows you to map a field from a Custom Metadata Type record.
    • Clicking the Edit icon will open the Custom Metadata selector.
  5. Custom Setting: This allows you to map a field from a Hierarchy or List Custom Setting record
    • Clicking the Edit icon will open the Custom Setting selector.

 

 If you select the Node Type as “Built using an Apex Class“, you can generate the value of the node using an Apex class. You can now mention the class name to use.

The selected class needs to be global and extend the d_wh.GenerateStringCallable abstract class.Below is an example class that can be used to generate the header value:

global class TestCallable extends d_wh.GenerateStringCallable {

    global override String Generate(List<Id> mainRecordIds) {

        // Add code to generate the string to be used as the value of the item

        // return mainRecordIds[0];

    }

}

The mainRecordIds parameter contains the list of ids of the main record(s). If the callout is a “One Record” type, the list will contain one Id. If no Main Object is selected, the list will be empty.The response should be a string and is going to be used as the item value when the callout is made.

 

Create from sample body

If you have a body Sample from the API documentation from the app or platform being implemented, you can create your Request Body quickly by utilizing the ‘Generate from sample body’ button. This enables you to quickly map your Main Object to your external system bypassing creating Node Names with stand-in values.

Copy the sample Request Body and paste it into the text box.

Click “Generate and replace exiting body” and you will see this has been added into the Request Body of your Callout Template. From here, you can begin mapping Salesforce fields from your Main Object by selecting the edit icon next to the row and replacing the static values from the sample body. This helps you to quickly map without having to manually create each Node Name with a provided guide from your external system API documentation.

NOTE: If you have started mapping in the fields in the body and you opt to utilize the ‘Generate from sample body’ button, your previous mapping will be overwritten. It is advised you begin with your sample body first before mapping additional Nodes.