Find us at our new Help Center where we've combined our documentation and knowledgebase articles in one easy-to-search location.
We aren't updating the Developer Portal anymore, except for the Element Docs — all updates happen in the Help Center. We're retiring the Developer Portal as you know it in:
Formulas are comprised of triggers that kick off formulas, steps that the trigger executes, and variables used to define inputs to the formula instance. The triggers, steps, and variables build up context that you can refer to as you build a formula. For example, a JS Script step might build a JSON payload that you can refer to in a later step as ${steps.stepName}
. Within a formula's context, you can refer to steps as as ${steps.stepName}
, variables as ${config.variableName}
, triggers as ${trigger.triggerComponent}
(such as ${trigger.args}
or ${trigger.event}
), and formula metadata as ${info.metadataName}
. Make sure that the dollar sign is outside of the curly brackets (${steps.stepname}
not $steps.stepName
) and that you don't take any shortcuts like ${stepName}
.
This section provides configuration information about each formula component.
Triggers are the actions that kick off a formula. Triggers can be one of the following types:
You can set up triggers that listen for an event to happen on an element instance. To set up this trigger, you must use an Element Instance Variable that, when specified in a formula instance, refers to an element instance that is configured to use webhooks or polling to listen for events.
To set up an Event trigger, you must specify an Element Instance Variable. Click to find or create a variable to represent the element instance that will kick off a formula instance when an event occurs.
If an Event trigger's Element Instance is set up for polling instead of webhooks, then each object that is found while polling triggers a separate formula execution. For example, if the poller finds five changes, five different formula executions kick off.
To see event triggers in action, see the following examples:
Event triggers add step execution values like those described in the example JSON below to the formula context. The formula context is then passed from step-to-step, allowing you to use these values in any subsequent steps in your formula.
{
"eventId": 11211123,
"instanceId": 231232132,
"type": "event",
"event": {
"date": "2016-06-01T04:09:10Z",
"elementKey": "sfdc",
"eventType": "UPDATED",
"objectId": "n005i000003sgTd0AAE",
"objectType": "Contact"
}
}
Example references to Event trigger scope:
${trigger.event.objectType}
${trigger.event.eventType}
Triggered any time a specific API call is made to a given Element Instance. To set up this trigger, you must use an Element Instance Variable that, when specified in a formula instance, refers to an element instance.
When you set up an Element Request trigger, specify the following parameters:
hubs/crm/contacts
.Triggered at times specified by a Cron job. We recommend that you review the many reference pages for Cron jobs online.
In general, the Cron format consists of:
Minute 0-59 | Hour0-23 | Day of Month1-31 | Month of Year1-12 | Day of Week1-7Monday-Sunday | Year1900-3000 |
---|---|---|---|---|---|
* | * | * | * | * | * |
Run every 15 minutes
0 0/15 * 1/1 * ? *
Run every Monday at noon
0 0 12 ? * MON *
8.00 PM every weekday (Mon-Fri):
0 0 8 ? * MON,TUE,WED,THU,FRI *
midnight on 1st ,10th & 15th of month
0 0 0 1,10,15 1/1 ? *
To see a Scheduled trigger in action, see Bulk Transfer CRM Data
Triggered via a manual API call to POST /formulas/instances/:id/executions
. Manual triggers do not require any specific configuration. You can use formulas triggered manually as synchronous API calls. See Formula as a Resource for setup instructions.
To see a Scheduled trigger in action, see Bulk Transfer CRM Data
You can choose from several different types of steps to make up your formula. You can refer to any step with the ${steps.stepName syntax}
. Because you refer to the step by name, each step name must be unique within each formula. However, you can reuse a step name in a different formula.
You can use the following types of steps in your formulas:
The ActiveMQ Request (amqpRequest
) step type uses the AMQP protocol to post a message to an MQ server such as RabbitMQ.
When you set up an ActiveMQ Request step, include the following information:
Parameter | Description | Required |
---|---|---|
Namename |
The name of the formula step. The name must be unique within the formula. | Y |
URLurl |
Specifies the AMQP URL endpoint of the MQ Server. The structure of the URL is specified in RabbitMQ URI Specification. | Y |
Queuequeue |
Indicates the name of the queue of the MQ server to which the message should be posted. | Y |
Messagebody |
The JSON payload to post to the server. | Y |
Exchangeexchange |
The name of the MQ server exchange to which the message should be posted. | N |
ActiveMQ Request steps add the step execution values described in the example JSON below to the formula context. The formula context is then passed from step-to-step, allowing you to use these values in any subsequent steps in your formula.
{
"myAmqStep": {
"request": {
"body": "{\"message\":\"This is a test message.\"}",
"url": "amqp://otqaqsml:tPpXwTl7-iMtezRmyJmD-y2U_XbroYpW@jaguar.rmq.cloudamqp.com/otqaqsml",
"exchange": "main",
"queue": "myqueue"
}
}
}
Example references to ActiveMQ Request scope:
${steps.myAmqStep.request}
${steps.myAmqStep.request.body}
The Element API Request (elementRequest
) step makes an API call to a specific Element Instance.
To see an Element API Request step in action see:
When you set up an Element API Request step, include the following information:
Parameter | Description | Required |
---|---|---|
Namename |
The name of the formula step. The name must be unique within the formula. | Y |
Element Instance VariableelementInstanceId |
Specifies the element instance that receives the API call. | Y |
Methodmethod |
The API method of the API call, such as GET, POST, PUT, PATCH, or DELETE. | Y |
APIapi |
The endpoint, such as hubs/crm/contacts . |
Y |
Headersheaders |
The headers to pass along as part of the API request. You rarely need to add anything to the headers, but you can use this parameter to pass common header information such as content types. | N |
Queryquery |
Any query parameters, such as a CEQL query or pagination, to pass as part of the API request. | N |
Pathpath |
Support earlier formulas where path defined variables, such as an {ID} variable in an endpoint. In the latest version, the path parameter is unnecessary. |
N |
Bodybody |
Specifies the JSON body to send with the related request. Construct the JSON body in another step and refer to it in the body parameter. For example, ${steps.previousStep.body} . |
N |
Acceptable CodesacceptableStatusCodes |
A comma-separated list (200,201 ) of codes, range (200-205 ), or both (200-205,208 ) returned in the response that indicates success. |
N |
Retry on Failureretry |
Indicates that we should retry a configurable number of times if the request fails. | N |
Max Retry AttemptsretryAttempts |
The maximum number of times to retry the request. | N |
Retry DelayretryDelay |
The time in milliseconds to wait between retries. | N |
Retry Status CodesretryStatusCodes |
A comma-separated list (500,502 ) of codes, range (400-415 ), or both (400-415,500,502 ) returned in the response that indicates that we should retry the request. |
N |
Element API Request steps add the step execution values described in the example JSON below to the formula context. The formula context is then passed from step-to-step, allowing you to use these values in any subsequent steps in your formula.
{
"myElementRequestStep": {
"request": {
"query": "{}",
"body": "{\"Name\":\"New Account Name\"}",
"method": "POST",
"path": "{}",
"uri": "/elements/api-v2/hubs/crm/accounts",
"headers": "{\"authorization\":\"Element /ABC=, User DEF=, Organization GHI\",\"content-length\":\"14\",\"host\":\"jjwyse.ngrok.io\",\"content-type\":\"application/json}"
},
"response": {
"code": "200",
"headers": "{\"Set-Cookie\": \"CESESSIONID=2CA15552EE56EAF65BF1102F6CACEACC;Path=/elements/;HttpOnly\"}",
"body": "{\"Id\": \"001tx3WcAAI\", \"Name\": \"New Account Name\"}"
}
}
}
Example references to Element API Request scope:
${steps.myElementRequestStep.request}
${steps.myElementRequestStep.request.body}
${steps.myElementRequestStep.response.code}
The HTTP Request (httpRequest
) step make an HTTP/S call to any URL/endpoint.
When you set up an HTTP Request step, include the following information:
Parameter | Description | Required |
---|---|---|
Namename |
The name of the formula step. The name must be unique within the formula. | Y |
Methodmethod |
The API method of the API call, such as GET, POST, PUT, PATCH, or DELETE. | Y |
HTTP/S URLurl |
The full URL of the request. | Y |
Headersheaders |
The headers to pass along as part of the API request. You rarely need to add anything to the headers, but you can use this parameter to pass common header information such as content types. | N |
Queryquery |
Any query parameters, such as a CEQL query or pagination, to pass as part of the API request. | N |
Pathpath |
Support earlier formulas where path defined variables, such as an {ID} variable in an endpoint. In the latest version, the path parameter is unnecessary. |
N |
Bodybody |
Specifies the JSON body to send with the related request. Construct the JSON body in another step and refer to it in the body parameter. For example, ${steps.previousStep.body} . |
N |
Acceptable CodesacceptableStatusCodes |
A comma-separated list (200,201 ) of codes, range (200-205 ), or both (200-205,208 ) returned in the response that indicates success. |
N |
Retry on Failureretry |
Indicates that we should retry a configurable number of times if the request fails. | N |
Max Retry AttemptsretryAttempts |
The maximum number of times to retry the request. | N |
Retry DelayretryDelay |
The time in milliseconds to wait between retries. | N |
Retry Status CodesretryStatusCodes |
A comma-separated list (500,502 ) of codes, range (400-415 ), or both (400-415,500,502 ) returned in the response that indicates that we should retry the request. |
N |
HTTP Request steps add the step execution values described in the example JSON below to the formula context. The formula context is then passed from step-to-step, allowing you to use these values in any subsequent steps in your formula.
{
"myHTTPRequestStep": {
"request": {
"query": "{}",
"body": "{\"Name\":\"New Account Name\"}",
"method": "POST",
"url": "https://api.myservice.com:443/myresource",
"path": "{}",
"headers": "{\"authorization\":\"mysessionid\",\"content-type\":\"application/json}"
},
"response": {
"code": "200",
"headers": "{\"Set-Cookie\": \"CESESSIONID=2CA15552EE56EAF65BF1102F6CACEACC;Path=/elements/;HttpOnly\"}",
"body": "{\"id\": \"237648\", \"name\": \"My New Resource Name\"}"
}
}
}
Example references to HTTP Request scope:
${steps.myHTTPRequestStep.request}
${steps.myHTTPRequestStep.request.body}
${steps.myHTTPRequestStep.response.code}
Use the JS Filter (true/false) (filter
) step to write custom Javascript that must return true or false. As with all steps, you must include a name. See Javascript in Formulas for more information about working with Javascript in formulas.
Use JS Filter steps to specify only certain event types, field values, or other information. You can also use filters to split formulas into different paths.
true
, the formula executes the left, or OnSuccess , step.false
, the formula executes the tight, or OnFailure , step.To see a JS Filter step in action see:
JS Filter steps pass a boolean into the JS done
callback function. That boolean is made available under the key titled continue
, as shown in the examples below.
{
"myFilterStep": {
"continue": "true"
}
}
{
"myFilterStep": {
"continue": "false"
}
}
Use the JS Script (script
) step to write custom Javascript that must pass a valid JSON object to the done
callback. As with all steps, you must include a name. See Javascript in Formulas for more information about working with Javascript in formulas.
Use JS Script steps to build objects to use in request steps for query parameters or the request body.
console.log
in a JS Script step, the output is added to the body of the step. If you reference the script step in another step as just ${steps.stepName}
, the console.log
output is added to the step context and can cause errors. Prevent this by declaring what to include in the step body by adding it to done
. For example, done({body.variableName})
. To see a JS Script step in action see:
JS Script steps add whatever object is passed to the JS done
callback to the formula context. The formula context is then passed from step-to-step, allowing you to use these values in any subsequent steps in your formula.
done({
foo: 'bar',
object: {
someKey: 'someValue'
}
});
Example references to JS Script scope:
${steps.myScriptStep.foo}
${steps.myScriptStep.object}
${steps.myScriptStep.object.someKey}
Use the Loop Over Variable (loop
) step to loop over a list of objects from a previous step or trigger. Set onSuccess
to the first step in the loop. When you have reached the last step in the loop set the onSuccess field to the loop step, this will restart the loop for the next object. If you need to continue on after the loop is completed, set onFailure
to the next step to execute after the loop is completed. For a loop step, onFailure
is executed when the loop has been executed for all objects in the list.
When you set up a Loop Over Variable step, include the following information:
Parameter | Description | Required |
---|---|---|
Namename |
The name of the formula step. The name must be unique within the formula. | Y |
Listlist |
A reference to a previous step that provides a list of items to loop through. | Y |
Loop Over Variable steps make available the current object being processed and the index to each step executed inside of that loop. For example, if we have a loop
step named looper
, any steps that are run inside of that loop would have access to looper.index
and looper.entry
.
Example references to Loop scope:
${steps.myLoopStep.entry.id}
${steps.myLoopStep.index}
The Platform API Request (request
) step makes an API call to one of our platform APIs.
When you set up a Platform API Request step, include the following information:
Parameter | Description | Required |
---|---|---|
Namename |
The name of the formula step. The name must be unique within the formula. | Y |
Element Instance VariableelementInstanceId |
Specifies the element instance that receives the API call. | Y |
Methodmethod |
The API method of the API call, such as GET, POST, PUT, PATCH, or DELETE. | Y |
APIapi |
The endpoint, such as hubs/crm/contacts . |
Y |
Headersheaders |
The headers to pass along as part of the API request. You rarely need to add anything to the headers, but you can use this parameter to pass common header information such as content types. | N |
Queryquery |
Any query parameters, such as a CEQL query or pagination, to pass as part of the API request. | N |
Pathpath |
Support earlier formulas where path defined variables, such as an {ID} variable in an endpoint. In the latest version, the path parameter is unnecessary. |
N |
Bodybody |
Specifies the JSON body to send with the related request. Construct the JSON body in another step and refer to it in the body parameter. For example, ${steps.previousStep.body} . |
N |
Acceptable CodesacceptableStatusCodes |
A comma-separated list (200,201 ) of codes, range (200-205 ), or both (200-205,208 ) returned in the response that indicates success. |
N |
Retry on Failureretry |
Indicates that we should retry a configurable number of times if the request fails. | N |
Max Retry AttemptsretryAttempts |
The maximum number of times to retry the request. | N |
Retry DelayretryDelay |
The time in milliseconds to wait between retries. | N |
Retry Status CodesretryStatusCodes |
A comma-separated list (500,502 ) of codes, range (400-415 ), or both (400-415,500,502 ) returned in the response that indicates that we should retry the request. |
N |
Platform API Request steps add the step execution values described in the example JSON below to the formula context. The formula context is then passed from step-to-step, allowing you to use these values in any subsequent steps in your formula.
{
"myPlatformStep": {
"request": {
"query": "{}",
"body": "{\"Name\":\"New Account Name\"}",
"method": "POST",
"path": "{}",
"uri": "/elements/api-v2/hubs/crm/accounts",
"headers": "{\"authorization\":\"Element /ABC=, User DEF=, Organization GHI\",\"content-length\":\"14\",\"host\":\"jjwyse.ngrok.io\",\"content-type\":\"application/json}"
},
"response": {
"code": "200",
"headers": "{\"Set-Cookie\": \"CESESSIONID=2CA15552EE56EAF65BF1102F6CACEACC;Path=/elements/;HttpOnly\"}",
"body": "{\"Id\": \"001tx3WcAAI\", \"Name\": \"New Account Name\"}"
}
}
}
Example references to Platform API Request scope:
${steps.myPlatformStep.request}
${steps.myPlatformStep.request.body}
${steps.myPlatformStep.response.code}
Retry Formula on Failure (retryFormulaExecution
) retries a formula instance execution with the same input data. You can configure the number of retry attempts, with a maximum of 7 attempts. The retry time is set based upon an exponential backoff in minutes. The equation used for the exponential backoff is round(e^x)
where x
is the retry attempt number.
When you set up a Retry Formula on Failure step, include the following information:
Parameter | Description | Required |
---|---|---|
Namename |
Y | |
Max Retry AttemptsretryAttempts |
The maximum number of times to retry the request. | N |
Retry Formula on Failure steps truncate the formula execution and schedule a retry execution for a later time based upon the retry attempt number. The result of this equation is used to schedule a retry in minutes. The step execution response value for this step is a string
as shown in the example below.
{
"id": "53067",
"key": "retry.error",
"value": "Formula instance execution scheduled for retry at approximately 2016-12-05T08:52:37-07:00"
}
In this example, the step name in the formula is retry
, and the value of the step execution indicates the time when the formula execution will be retried.
Stream File (elementRequestStream
) steps move a file from one Element Instance to another. Stream Files steps configure two API requests instead of just one. One request downloads the date from an element instance, and the second request uploads the data to another. Use the response body of the download request as the request body of the upload request.
To see a Stream File step in action see Bulk Transfer CRM Data.
When you set up a Stream File step, include the following information:
Parameter | Description | Required |
---|---|---|
Namename |
The name of the formula step. The name must be unique within the formula. | Y |
Download/Upload Element Instance VariableuploadElementInstanceId /downloadElementInstanceId |
Specifies the element instance that receives the API call. | Y |
Download/Upload MethoduploadMethod /downloadMethod |
The API method of the API call, such as GET, POST, PUT, PATCH, or DELETE. | Y |
Download/Upload APIuploadApi /downloadApi |
The endpoint, such as hubs/crm/contacts . |
Y |
Download/UploadHeadersuploadHeaders /downloadHeaders |
The headers to pass along as part of the API request. You rarely need to add anything to the headers, but you can use this parameter to pass common header information such as content types. | N |
Download/UploadQueryuploadQuery /downloadQuery |
Any query parameters, such as a CEQL query or pagination, to pass as part of the API request. | N |
Upload Form DatauploadFormData |
Specifies the form data to send with the related request. Construct the form data in another step and refer to it in the Upload Form Data parameter. For example, ${steps.previousStep.formdata} . |
N |
Upload Form Parameter NameuploadFormDataName |
Specifies the name of the form parameter. | N |
Stream File steps add the step execution values described in the example JSON below to the formula context. The formula context is then passed from step-to-step, allowing you to use these values in any subsequent steps in your formula.
{
"myStreamStep": {
"download": {
"request": {
"query": "{}",
"method": "POST",
"uri": "/elements/api-v2/hubs/crm/accounts",
"headers": "{\"authorization\":\"Element /ABC=, User DEF=, Organization GHI\",\"content-length\":\"14\",\"host\":\"jjwyse.ngrok.io\",\"content-type\":\"application/json}"
},
"response": {
"code": "200",
"headers": "{\"Set-Cookie\": \"CESESSIONID=2CA15552EE56EAF65BF1102F6CACEACC;Path=/elements/;HttpOnly\"}"
}
},
"upload": {
"request": {
"query": "{}",
"method": "POST",
"uri": "/elements/api-v2/hubs/crm/accounts",
"headers": "{\"authorization\":\"Element /ABC=, User DEF=, Organization GHI\",\"content-length\":\"14\",\"host\":\"jjwyse.ngrok.io\",\"content-type\":\"application/json}"
},
"response": {
"code": "200",
"headers": "{\"Set-Cookie\": \"CESESSIONID=2CA15552EE56EAF65BF1102F6CACEACC;Path=/elements/;HttpOnly\"}",
"body": "{\"Id\": \"001tx3WcAAI\", \"Name\": \"New Account Name\"}"
}
}
}
}
Example references to Stream File scope:
${steps.myStreamStep.download.request.query}
${steps.myStreamStep.upload.request.headers}
${steps.myStreamStep.upload.response.body}
Sub-Formula (formula
) steps run another formula instance.
When you set up a Sub-Formula step, include the following information:
Parameter | Description | Required |
---|---|---|
Namename |
The name of the formula step. The name must be unique within the formula. | Y |
Sub-Formula (ID)formulaId |
The ID of the formula. | Y |
args |
Any values that should be made available to the sub formula. | N |
subFormulaConfigs |
Any variables required for the sub formula. | N |
Sub-Formula steps add the values produced as the result of the last step in the sub-formula. Therefore, we recommend that when you build formulas to be used by other other formulas that you add a specific step to aggregate and returns whatever data is needed in the parent's formula context.
If the sub-formula requires variables, then those variables can either be set in the parent formula instance using the same config names or passed in via the subFormulaConfigs
property. All sub-formulas inherit their parent formula's configuration values. If you pass in the subFormulaConfigs
these are added to the list of existing configs from the parent and the sub-formula has access to the parent's configs and those passed in with the values in subFormulaConfigs
taking precedence.
The args
can be accessed in the sub-formula using trigger.args
. The subFormulaConfigs
can be accessed in the sub-formula using config for example: ${config.crmInstanceId}
.
Formulas include two types of variables that you must specify when you run a formula instance:
Formula variables are limited to the formula and cannot have the same name. However, you can name variables in different formulas with the same name like "originInstance" or "destinationInstance."
Formula variables contribute to the formula context and you refer to them by their Formula Step Variable Name. This name is always config.variableName
. So, if you create an Element Instance Variable called originInstance
, you refer to it as ${config.originInstance}
. A Value Variable called objectName
is referred to as ${config.objectName}
.