Skip to main content

Executing Rules from a REST Endpoint

As of v5.7.3 rules may also be executed by interacting with the Decision Client over REST. This easily enables external workflows, such as Power Automate, to execute rules from the Decision Client. A POST endpoint is available on the Decision Client that will accept a request to execute rules and return a response containing information on the entity changes or information about errors encountered.

Authentication with Salesforce

Before sending your request to execute rules, an access token needs to be retrieved. This will be used in the rule execution request to authenticate with the Salesforce REST API. Below is an example request body that might be used to in a POST request to your login URL to receive an access token. More information about REST API authorization can be found in the Salesforce REST API Developer Guide.

{
"grant_type": "password",
"client_id": "{{clientId}}",
"client_secret": "{{clientSecret}}",
"username": "{{username}}",
"password": "{{password}}{{secretToken}}"
}

Rule Execution Request

The URI for Decision Client rule execution REST endpoint will use the subdomain for your Salesforce org.

https://{{DomainName}}.my.salesforce.com/services/apexrest/inrule/executerules

The access token from the authorization request will then need to be provided as a bearer token in your authorization headers.

Finally, you will need to supply the body for your salesforce request. Below is information on the request parameters that can be sent as part of your Rule Execution Request, as well as an example request body.

Parameter NameDescription
Id (String)The unique Salesforce identifier for the root object in the request. This is a property available on all Salesforce objects and be accessed with: "entityName.Id"
ObjectType (String)The Salesforce object type of the root object in the request. For example, if running rules against an Account entity, this will need to be set to a string value of "Account".
RuleSetName (String)The name of an explicit Rule Set to call as the entry point for rule execution.
RuleAppName (String) (Optional)Optional. Defining and passing a RuleAppName here allows you to override the default Rule App Name defined in your Custom Setting created during initial configuration for this specific button. If you do not wish to override your Custom Setting, pass null here.
RuleAppLabel (String) (Optional)Optional. Defining and passing a rule app label here allows you to override the rule app label configured on the execution service. If you do not wish to override your execution service's configuration, pass null here.
EntityImage (String) (Optional)Optional. This allows you to pass in the serialized JSON string of an entity image as it exists at the time of calling the DecisionClient, which will have rules execute against the entity image passed in, not the entity image as it exists in Salesforce when the execution process reaches the execution service. If you do not wish to pass this in, pass null instead.
PersistChanges (Boolean) (Optional)Optional. This allows you to define whether to persist data changes made during rule execution to Salesforce. Pass in null to default this value to true.
{
"Id": "0016g000015JnOnAAK",
"ObjectType": "Account",
"RuleSetName": "AccountDefaultRules",
"RuleAppName": "SalesforceRules",
"PersistChanges": false
}