---
schema_version: "1"
id: 2147852c7f68ed3ddfe6527e992e65b14371ac79ba88fffe953a3ab06a23d24c
title: Edit Rules Files
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_wave_templates/guides/concept/bi-templatesdev-edit-rules-json.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/guide/bi-templatesdev-edit-rules-json.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0377051e234175bd9b98bb0ed4c73e850cb39cc9489742b1cc9eb38d64ba69d0
products:
  - Analytics Templates Developer Guide
  - analytics
---

# Edit Rules Files

Rules files define how an app gets created by the template.

There are two type of rules files: `template-to-app-rules.json` and `app-to-template-rules.json`. They use the same syntax, but serve different purposes.

- `template-to-app-rules.json` defines the rules that the template follows when creating an app. For example, you can define a rule that specifies that if an org doesn’t use certain objects, the app doesn't use them in dashboards or the dataflow. Another rule can replace a label name in a chart with the name of a field from a Salesforce object selected in a wizard question. Rules also define how variables are handled. For example, if the wizard asks which fields to include in filters for accounts, `template-to-app-rules.json`determines how that choice is reflected in dashboards.
- `app-to-template-rules.json` provides rules for converting an updated source app back to template form. After changing the source app, you update the template object with a PUT call to the CRM Analytics REST API. For example, you can tokenize all asset files every time they are pulled out of the source app. You use app-to-template rules infrequently, because you're unlikely to update the source app often.

The rules file is referenced from `template-info.json`:

```nolang
"rules" : [
    { "type" : "appToTemplate", "file" : "appToTemplateRules.json" },
    { "type" : "templateToApp", "file" : "templateToAppRules.json" }
],
```

The bulk of what follows details the use of `template-to-app-rules.json`.

- **[Rules Files Structure](https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/guide/bi-templatesdev-rules-files-structure.md)**


    Rules files can contain three sections: rules, constants, and macros.

- **[Structuring and Organizing Rules](https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/guide/bi-templatesdev-rules-structure.md)**


    The rules section of `template-to-app-rules.json` defines the rules followed by the template.

- **[Rules Syntax](https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/reference/bi-templatesdev-rules-syntax.md)**


    The rules object may contain any number of rule objects. A rule object is made up of:

- **[Actions in Rules](https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/guide/bi-templatesdev-actions-in-rules.md)**


    Actions define what a rule does. Use constants to make it easier to perform any action.

- **[Actions Syntax for Rules](https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/reference/bi-templatesdev-actions-syntax-rules.md)**

- **[Use Functions in Rules](https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/reference/bi-templatesdev-functions.md)**


    Functions make rules more powerful. For example, use functions to apply rules iteratively to arrays or to make rules conditional on the content of a string or an array. CRM Analytics Templates supports string, array, and json functions as well as static math and sfdc_fma functions.

- **[Macros in Rules](https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/guide/bi-templatesdev-macros-in-rules.md)**


    Use a macro when a single rule executes repeatedly on different JSON node paths.

**See Also**

- [rules.json Attributes](https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/reference/bi-templatesdev-rules-json-attributes.md)
