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

Pages

Step 2: Callout Template Headers

Callout Template Header Page

In this step we will review Callout Headers. Default headers for Content-Type and Accept are automatically added to the list but be sure to check the external platform API documentation in detail if additional headers are required.

 

To add additional Headers, select the Plus icon button.  

Merging fields

  • You can include merge fields from your selected Salesforce Main Object of this template in Header Value. Field names used in Header Value must be entered as the API field name (not Label) for example: {!APIFIELD}.  If you need to reference a field from a related object, use this format: {!Custom_Relation__r.Custom_Field__c}
  • If you need to include a custom metadata field in the URL, you can merge using this format: {!$CustomMetadata.CustomMetadataTypeAPIName.RecordAPIName.FieldAPIName}, for example: {!$CustomMetadata.Metadata__mdt.Record1.Field1__c}
  • If you need to include a field from a List Custom Settings, you can merge using this format: {!$CustomSetting.CustomSettingAPIName.RecordName.FieldAPIName}, for example: {!$CustomSetting.List_CS__c.Record1.Field1__c}
  • If you need to include a field from a Hierarchy Custom Settings, you can merge using this format: {!$CustomSetting.CustomSettingAPIName.FieldAPIName}, for example: {!$CustomSetting.Hierarchy_CS__c.Field1__c}

 

Generate a header value with Apex

If the header value is too complex, you have the option to generate a header value using an Apex class. Click on the edit icon.

This will open a popup letting you enter a class name

The 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 generate and return the header value

        // 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 header value when the callout is made.

NOTE: Do NOT add authorization headers here. Auth headers will be automatically added by the system when the callout is made, based on the Authentication details you provided in the first step.

Once you have completed your Headers, press Save and Continue to move to the Request Body Page.