---
schema_version: "1"
id: 752acd7f78e30e59aaba84929ecb49a1169bb74149bdd85e919b0cf4040aaac8
title: Actions Syntax for Rules
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_wave_templates/guides/reference/bi-templatesdev-actions-syntax-rules.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/guide/bi-templatesdev-actions-syntax-rules.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 351aa88748266c960f497adecc98653f4d0d9e6769ef64af10e8074206ec052f
products:
  - Analytics Templates Developer Guide
  - analytics
---

# Actions Syntax for Rules

| Action    | Example | Notes                                                                                                                                                                                                                                                                                                                                                                    |
| --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `add`     |         | Adds an entry to an existing array. Needs `"index"` and `"value"`. `"index"` should be 0 for the first element in the array, any number after that for the middle of the array. If `"index"` is larger than the array size, the value is added to the end of the array.                                                                                                  |
| `put`     |         | Add an attribute and value to an existing JSON value. Needs `"key"` and `"value"`. `"value"` can be a string or an array.                                                                                                                                                                                                                                                |
| `set`     |         | Set a value on an existing JSON attribute. Needs `"value"`.                                                                                                                                                                                                                                                                                                              |
| `delete`  |         | Remove a node in the existing JSON tree.                                                                                                                                                                                                                                                                                                                                 |
| `eval`    |         | Evaluate the expression specified in `'value'` and assign results to the context variable specified by `'key'` (if set). Context attribute can be referenced using the expression: `${Rules.Eval.<variable_name>}`. The scope of the eval variable is the entire document if performed in a rule, or the macro if performed within a macro.                              |
| `replace` |         | Replace any text string throughout the entire document. Use when regular expressions are not an option. Can still use expressions. Instead of using the `'replace'` action, you can perform targeted search and replace (JSON Path) with `${string:replace(...)}`. In cases requiring regular expressions, use `${string:replaceFirst(...)}, ${string:replaceAll(...)}`. |

Example `add` action:

```nolang
{
    "action": "add",
    "description" : "Add desc",
    "path": "$.json.path.to.existing.json,array",
    "index": 0,
    "value": "value to add"
}
```

Example `put` action:

```nolang
{
    "action": "put",
    "description" : "Put desc",
    "path": "$.json.path.to.existing.json",
    "key": "jsonAttributeName",
    "value": "new value"
}
```

Example `set` action:

```nolang
{
    "action": "set",
    "description" : "Set desc",
    "path": "$.json.path.to.attribute",
    "value": "setValue"
}
```

Example `delete` action:

```nolang
{
    "action": "delete",
    "description" : "Delete desc",
    "path": "$.json.path.to.delete"
}
```

Example `eval` action:

```nolang
[
    {
        "action": "eval",
        "key": "helloResult",
        "value": "${myMacros:sayHello('Hello')}"
    },
     {
        "action": "set",
        "path": "$.path.json.node",
        "value": "${Rules.Eval.helloResult}"
    }]
```

Example `replace` action:

```nolang
{
 "action": "replace",
 "key": "RPLCM_Opportunity_Amount_Field",
 "value": "${Variables.Opportunity_Amount.fieldName}"
},
```
