Initiate a Sequence from a button
Start a Callout Sequence with a record page button
To start a callout sequence from a page button or list view button on your Main Object, you will follow the traditional steps in creating an object button according to Salesforce documentation with a few specific details.
In Set Up, select Object Manager and find your Main Object specified in your Callout Template. On the left select Buttons, Links, and Actions followed by ‘New Button or Link.’
Provide the following on the New Button or Link screen:
- Label: Enter a name for your new button
- Description: Provide a short description of what template is being called
- Display Type: Select Detail Page Button
- Behavior: Display in existing window with sidebar (or preferred choice)
- Content Source: URL
In the body of the New Button or Link section, you will need enter the following URL, to which you will add additional parameters.
/apex/d_wh__StartSequence?
Parameters you can add to the URL:
- sequenceDevName=… or sequenceId=…
- Only one of these parameters is mandatory when initiating the sequence. These parameters are used to identify the sequence to use. The recommended one is sequenceDevName, because you don’t hardcode sequence ids in your Salesforce setup.
- You can identify your Sequence Id / Sequence Developer Name under the Administration tab – Callout Sequences subtab in the Declarative Webhooks app
- &recordId=…
- If the sequence you selected has a Main Object, then the recordId parameter is mandatory to identify the record to use when making the callouts. You will use the ID of the Main Object from your sequencee. If your Main Object is Account then you can use recordId={!Account.Id} for a page layout button, or recordId={!Opportunity.Id} and so on.
- &viewResult=TRUE
- Optional Parameter. If you want the end user to view the callout sequence status after it’s initiated.
- &returnUrl=/URLhere
- Optional Parameter. After clicking the Initiate Sequence button, by default, the user will return to the record that they started the sequence from. If you want to redirect your user to a new page after they make the call, provide a returnURL. Some examples include redirecting the user to a list of Accounts in Salesforce, a next step page (Visualforce) or displaying a success message to the user. The returnUrl can’t be an external URL. It needs to be a relative URL.
- &message=…
- Optional Parameter. This is a message that the user will see after clicking the button and before the sequence is initiated. It’s an unsafe practice to make the callout or change records directly when the page loads, so the user will see a message before making the actual callout. If this parameter is not added to the URL, a default message will be displayed. Make sure to URL-Encode the message.
- &buttonLabel=…
- Optional Parameter. If you add this parameter, the “Initiate Callout Sequence” button will be renamed with the value of this parameter. Make sure to URL-Encode the label.
- &title=…
- Optional Parameter. If you add this parameter, the Title the user sees on the page will be replaced with the value of this parameter. Make sure to URL-Encode the title.
- &successMessage=…
- Optional Parameter. If you add this parameter, after the sequence is initiated, the provided message will be displayed to the user. If this parameter is added, the returnUrl parameter will be ignored. Make sure to URL-Encode the message.
Here is an example of initiate sequence button URL:
/apex/d_wh__StartSequence?sequenceDevName=ExampleSequence&recordId={!Contact.Id}&returnUrl=/{!Contact.Id}
After you have completed your URL, select ‘Save’ at the top of the screen (and don’t forget to add your new Button to the Page Layout!).
NOTE: We recommend testing this in your Sandbox before Production.