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

Pages

Initiate a Sequence Using Apex

Start a Callout Sequence with Apex

You can use Apex to initiate a sequence.

  • d_wh.CalloutsManager.SequenceResponse res = d_wh.CalloutsManager.StartCalloutSequenceDN(sequenceDevName, recordId);
    • Use this method to initiate a sequence with a single record.
    • sequenceDevName is the Callout Sequence Developer Name of the sequence to use.
    • recordId is the Salesforce Id of the main record to use in this callout.
    • Returns the sequence details. See details about SequenceResponse below.
  • d_wh.CalloutsManager.SequenceResponse res = d_wh.CalloutsManager.StartCalloutSequence(sequenceId, recordId);
    • Use this method to initiate a sequence with a single record.
    • sequenceId is the Salesforce Id of the sequence to use.
    • recordId is the Salesforce Id of the main record to use in this callout.
    • Returns the sequence details. See details about SequenceResponse below.

 

The response from the StartCalloutSequence method is a d_wh.CalloutsManager.SequenceResponse class. It contains some information about the sequence that was initiated:

  • Id SequenceLogId – this is populated with the Salesforce Id of the generated sequence log record

 

The “StartCalloutSequenceDN” method uses the callout sequence developer name to identify a sequence, which is a field automatically generated when you create or edit a callout sequence. You can find it either in the callout sequence page layout, or in the Declarative Webhooks app -> Administration tab -> Callout Sequences subtab.

 

Test class support

If you are making a callout using the Apex methods above, you will need to write a test class to cover the code. In which case, you need to set a HttpCalloutMock class for the callout. If the code that performs the callout is in a managed package, the Test.setMock call needs to be done from a test method in the same package with the same namespace. So instead of the usual:

Test.setMock(HttpCalloutMock.class, mock);

you can do it like this:

d_wh.CalloutsManager.setMock(mock);

where mock is an instance of a class that implements HttpCalloutMock, as described in the Salesforce documentation ( https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm )