Notes and Tips
- This tutorial is presented for educational purposes only.
- Always test your rules before running them in a production environment.
- Understand your Salesforce environment before performing any operations which may affect your data.
Step 1 - Creating the Rule
- Click Administration > Rules Engine > click +Rule, or edit an existing one.
- Select Custom rule
- Select Account
- Enter a descriptive name for the rule
- (Optional) Add a description
- Click Next
Step 2 - Select Show Fields
This explains how to create aggregations using the Show and Filters areas of the Setup Rule page.
Source Data & Show Fields
- Select Native Data and the Usage Data object.
- Add the following fields to Show:
- Account:: Id
- Usage Data::User Activity
- Click the drop down arrow on User Activity and select the aggregation desired (this example uses AVG).
- Create the following filters:
- Usage Data::Date equals Subtract N Days from Rule Date 30
- Usage Data::Date equals Rule Date
Select Next at the bottom of the page to save the rule, this is how the rule is created using the Fields.
Step 3 - Second Creation - Calculated Fields
This section shows how to create an Aggregation using the calculated field.
The Show Field
- Select Native Data
- Select Usage Data from the drop down menu
- Drag in Account:Id into the Show field
- Do NOT drag anything into the Filters section
- Click Add Calculated Field
The Calculated Field - Comparison
This field will calculate the aggregation when comparing two different parts of data. In this tutorial the AVG will be calculated.
- Name the field
- Select Comparison or Aggregation (can only choose one)
- Set the first portion of the comparison (More description in next section)
- Set the second portion of the comparison
- This area is changed on a different page, it will demonstrate where later
- Click Ok
The Calculated Field - Aggregation
- Name the Field
- Can be changed back to Comparison (Can only choose one)
- Select how the type of calculation
- Select what is going to be compared
- Select the timeframe for the rule to run
- Type in how long ago the rule will check
- Select the timeline for the rule to look at
- Select this check box if the rule should self check for missing data. (I.e. Data only comes in every 5 days but its set to 7 days, it will drop those two days of no data.)
- This is changed on a different page that will be shown in the next section
- Click "Ok"
Changing the "Time Identifier: Created Date" box
- After clicking "Ok" it goes back to the rule creation page
- Scroll down and find the Time Identifier
- Using the drop down select a different Time Identifier.
- Click Next to save the rule
Time Identifier Changed
Back under the calculated field the Time Identifier will now be whatever was selected on the previous page.
Step 4 - Finishing the Rule
The rule is completed after clicking Next on either configuration as there is no action to be set up, as long as it will be run manually. If the rule should be run on a schedule then this final step will need to be completed.
Scheduling the Rule
- Select Schedule at the top
- Select how frequent the rule should be ran
- Select a start and end date if desired
- Choose a time in which the rule should run (best practice is to choose a non busy time to run before people look at the data)
- Where a failed rule will be emailed
- Select "Run for historical periods" if the rule should check previous points in time (I.E. Last 30 days)
- Click Start to have the rule start running