Create a Data Policy
From ISV Support Wiki
Contents |
Add a Data Policy
- Click Designer > Data > 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) Reads (on view, list view) 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. Modify search criteria. For example: Eliminate executive salary records from all queries, except for specific users. After Triggering Actions Take some action based on the data in the record. For example: Send an email when a count exceeds some threshhold. Modify data that will be displayed. For example: Mask social security numbers or update an access-count.
- 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)
- On View activates the policy when a record is viewed
- List View activates the policy when a multiple records are retrieved for viewing in a list
- 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 Role Based 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.
-
Packaging Options (optional)
- Choose whether to allow subscribers to disable the data policy.
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 Role Based 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.
-
Packaging Options (optional)
- Choose whether to allow subscribers to disable the data policy.
Add Actions to a Data Policy
Add actions that are invoked when the Data Policy is executed.
- Click Designer > Data > Objects > {object}
- Click the Data Policies tab
- Click the [New Policy] button to add a new policy, or click the name of an existing Data Policy
- Click the [New Action] button to add a new action
- Select the action to execute:
-
- 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
- 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.
-
- Invoke Java 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:
-
- Click [Save].
- Optionally, add additional actions, or [Reorder] the actions
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.