Create a Data Policy
Add a Data Policy
- Click Designer > Objects > {object}
- Click the Data Policies tab
- Click the [New Policy] button
- Enter the following information:
- Name
- Policy name
- Enabled
- Check the Enabled checkbox icon to enable the policy
- Select the Activation Trigger:
- Follow the instructions in sections below to build an action-based or calendar-based data policy.
Build an Action Based Data Policy
- Complete the steps to Add a Data Policy.
- Fill in the information described below.
- Click [Save]
- Policy Information
- Activation Sequence
- Choose whether to invoke the policy before or after the triggering actions occur, depending on what goals the data policy needs to achieve:
Writes (adds, updates, deletes) Before Triggering Actions Validate data before committing the action to the database. For example: Prevent the addition of duplicate records, or verify that an essential field is not empty. After Triggering Actions Take some action based on the data in the record. For example: Send an email when a count exceeds some threshhold.
- Triggering Action(s)
- Choose to invoke the data policy when any of these activities are applied to a record in the current object. Learn more: Available Triggers and Eligible Objects
- Add activates the policy when a record is added
- Update activates the policy when a record is updated
- Delete activates the policy when a record is deleted
- Ownership Change activates the policy when a record changes ownership (not available in Tasks/Appointments)
- Workflow State Change activates the policy when the workflow state changes
- Import Batch activates the policy during a batch import
- Import Record activates the policy when a record is imported
- Merge activates the policy when the Merge option is selected while Converting Prospect to Accounts
- Convert to Account activates the policy when converting Prospect to Accounts
- When Due activates the policy when a Task or Appointment becomes due (on End Date) (only available in Tasks/Appointments)
- Run As
- Executes an action using the permissions of the specified User, (not the User creating the data policy, or the User who causes the data policy to fire); Choose a User with the required Data Access Permissions to carry the actions defined in the policy.
- Date Criteria (optional)
- Select a field (Date Completed/Date Created/Date Modified/Due Date)
- Select an operator to specify a range of dates
- Optionally, add additional date criteria
- Field Criteria (optional)
- Specify fields and values to check for.
- Combine field checks into logical expressions using AND, OR, and parentheses
- Formula-Based Criteria (optional)
- Specify Filter Expressions:
- Select fields, operators, and functions.
- Type literal values in single quotes to complete the expression.
- Specify Filter Expressions:
Note:
- When building a formula, click the [Check Syntax] button to validate the expression.
- Remember that Policy Triggering Criteria expressions must resolve to a Logical type.
Build a Calendar Based Data Policy
- Complete the steps to Add a Data Policy.
- Fill in the information described below.
- Click [Save]
- Policy Settings
- Activation Date
- The date to start the actions
- Activation Time
- The time to start the actions
- Repeating Frequency
- Select a Repeating Frequency option to schedule repetitions.
- Run As
- Executes an action using the permissions of the specified User, (not the User creating the data policy, or the User who causes the data policy to fire); Choose a User with the required Data Access Permissions to carry the actions defined in the policy.
- Date Criteria (optional)
- Select a field (Date Completed/Date Created/Date Modified/Due Date)
- Select an operator to specify a range of dates
- Optionally, add additional date criteria
- Field Criteria (optional)
- Specify fields and values to check for.
- Combine field checks into logical expressions using AND, OR, and parentheses
- Formula-Based Criteria (optional)
- Specify Filter Expressions:
- Select fields, operators, and functions.
- Type literal values in single quotes to complete the expression.
- Specify Filter Expressions:
Note:
- When building a formula, click the [Check Syntax] button to validate the expression.
- Remember that Policy Triggering Criteria expressions must resolve to a Logical type.
Add Actions to a Data Policy
To specify the actions that occur when the Data Policy is executed:
- Click Designer > Objects > {object}
- Click the Data Policies tab
- Select an existing Data Policy or click [New Policy] to create a new one.
Note: When you create a new policy, you specify its triggering criteria, but it has no actions until you take the steps that follow. - Click the [New Action] button to add a new action
- Select one of the actions below:
- Click [Save].
- Optionally, add additional actions, or [Reorder] the actions
Create Task
To create a Task, complete the following fields:
- Action Name
- Name of the action
- Assigned To
- Select one of the following:
- Record Owner
- Supervisor of Record Owner
- Specific User
- System Administrator
- Subject
- Subject of the Task
- Days from trigger for when task is due
- Automatically make this task due for a specified number of days after the policy is triggered; '0' will use the Trigger Date as the Due Date
- Do not notify
- Turn off the notification message that would otherwise go out to the owner of the task.
- Description
- Task description
Send Email
To send an email message, complete the following fields:
- From
- Sender, choose from: Record Owner, Record Owner Supervisor, or a Specific User (opens a lookup window to Users)
- To
- Recipent(s), choose from: Record Owner, Record Owner Supervisor, Specific Email Addresses (opens a lookup window to Users and Contacts), System Administrator, Primary Contact, or other Related to options
- Cc
- Email address of person(s) who should be copied
- Bcc
- Email address of person(s) who should be blind-copied (these email addresses are hidden from all recipients, and are visible only to the sender)
- Subject
- Subject of the email message
- Editor Type
- Select a type of editor
- Learn More: Send Email
- Description
- Description of the message
Change Record Owner
Assign the record to a new owner.
Update Record
Change a field in the record (status, date, description, etc.)
- Considerations
- Data policies are executed after field validations occur. That sequence assures that the data policy is acting on valid data. (But it also means the data policy has the ability to put invalid data into the current record, since that data will not be validated.)
- Data policies are executed after formula-fields are evaluated. So if data in the current record is modified by the data policy, any relevant formula-field calculations need to be carried out by the data policy, since they will not occur automatically.
Send Outbound Message
In a Data Policy, it is possible to Send an Outbound Message via REST.
- Considerations
- The services which support HTTP POST requests can be accessed and the response HTTP status code is logged into the Debug Log
- For a pre-trigger action-based policy, the only available action is Invoke Java Method
- If the Delete triggering action is chosen, the only available action is Invoke Java Method
- To change a post-trigger policy to a pre-trigger policy, all actions associated with post-trigger policy must be deleted, since none of them are possible for a pre-trigger action
Note:
- Pre-trigger = Before Triggering Actions
- Post-trigger = After Triggering Actions
Post Item to Relay Feed
Use Relay to post a message.
Assign follower in Relay
Add a follower to a Relay feed.
Remove Follower in Relay
Remove a follower from a feed.
Invoke Method
Select a method to execute from an existing Java class.
Learn more: Invoke a Java Method From a Data Policy
- Considerations
- When modifying a different record (possibly in a different object), that modification will cause any relevant data policies to fire for that record, as well.
Execute Java Code
Give the action a name, and enter the Java code to execute.
Click [Select Java API] button to automatically enter code from a list of APIs for the platform.
Learn more:
Writing Java Code for a Data Policy
When an action-based data policy fires, a single record is processed. When a calendar-based data policy fires, multiple records may be processed.
In the latter case, the conditions defined by the data policy decide which rows will be processed. The Java code is invoked for each record that matches.
In both cases, the code needs to be written to operate on a single record.
Accessing the Incoming Parameters
To access the incoming parameters:
- When you Invoke a Java Method you declare the Parameters object as an argument in the method signature.
- When you Execute Java Code, the standard requestParams object is available. The requestParams object is an instance of Parameters. You don't have to declare it. You just use it, along with the other Java API Support Classes and Objects.
Tip: During updates, you can also use the getPriorParams method in the Parameters object to access the record's previous values.
Accessing and Updating Record Data
For most Data Policy triggers, record data is available as key/value pairs in the incoming Parameters object. Field names (not display labels) are the keys, and field contents are the values.
So if the Parameters object is named requestParams, the code to access and/or update the record data typically looks like this (in this case, to access String data):
String data = requestParams.get("field_name"); ... requestParams.put("field_name", data);
There are only a few exceptions to that rule:
- For a Data Policy action triggered by a Batch Import, record data is not available.
- For a Data Policy action triggered by the display of a single record (On View), the Parameters object contains a copy of the record data, so you can modify the view of the record without changing the underlying data. Assuming that the Parameters object is named requestParams, the code to access that data looks like this:
import com.platform.api.*; ... HashMap record = (HashMap) requestParams.getObject(CONSTANTS.RECORD.RESULT);
- For a Data Policy action triggered by the display of multiple records (List View), the Parameters object contains a list of records. You process that list using code like this:
import com.platform.api.*; ... ArrayList<HashMap> recordList = (ArrayList) requestParams.getObject(CONSTANTS.SEARCH.SEARCH_RESULTS); if (recordList != null && recordList.size() > 0) { for (HashMap record : recordList) { ... } }
In the latter two cases, once you have a record, you access and update field variables using code like this:
String data = record.get("field_name"); ... record.put("field_name", data);
Accessing Other Parameters
In addition to the record's field names and values, the following key/value pairs are included in the Parameters:
- policy_action
- This parameter contains one of the constants defined in the CONSTANTS.POLICY.ACTION class, to specify the trigger action that activated the data policy. (The "triggering action" is some event that occurred in the platform. The code you are writing, on the other hand, defines that "data policy action" that will be carried out, as a result.)
- action_event_sequence
- This parameter contains one of the constants defined in the CONSTANTS.POLICY.ACTIVATION class, to specify whether the data policy action is carried out before or after the triggering action.
- data_policy_id
- The ID of the data policy being executed.
- data_policy_action_id
- The ID of the data policy Action being executed.
- That value can be used to write re-usable classes or code that can handle a variety of conditions and data policies.