Rule parameters appear in the user interface and allow the administrator to enter values for the rule. Having parameters in rules is useful when certain values in a qualifier or an action may change and you prefer to have the administrator change the value through the user interface rather than modify the file. Parameterized rules are also useful because you can use the same file for multiple rules that each require different values.
Parameters for a wizard page action work in the same way as a rule, expect they appear in the wizard.
This section includes the following parameterized action samples:
•Specifying Due Date for Task Record Using Parameter
•Creating Project with Related History Using Parameters
The following sample automatically creates a task record when the user is saving a claim record for the first time. The due date of the task is set automatically according to the number of days specified by the administrator in the parameter, which appears as a field on the Rule screen in the user interface.
Business Rule |
When the Police Report Issued checkbox is selected in a Claim, the system creates a task. |
Action |
Creates a task to obtain a copy of the report with the following information in its fields: Parent Project: the Claim project. Assignee: Main project assignee. Description: Obtain a copy of the police report. Default Category: Follow-up:FNOL. Parameter: A Number field with the name "numberOfDaysAfter" and the label "The number of days between the date the claim was created and the due date" Due On: Parameter numberOfDaysAfter. |
Sample Values |
Object Definition: Claim or any custom object definition Rule Parameter Created: numberOfDaysAfter (Integer) Related Object Created: TASK (system object Task) Categories in Related Object: TASK_FLUP_FNOL Custom Fields: None |
Java Parameterized Action: Specifying Due Date for Task Record Using Parameter
public class SpecifyingDueDateForTaskRecord extends CustomAction<Project> {
@Override public void declareParameters() { parameters.addNumberParameter("numberOfDaysAfter", "The number of days between the date the claim was created and the due date", Long.valueOf(1)); }
@Override public void action(final Project project) { // Run as system user to bypass security platform.getUtilityService().runAsSystemUser(new Callable() { @Override public void call() { // Get the value of the rule parameter int numberOfDaysAfter = parameters.getNumberParameterValue("numberOfDaysAfter").intValue();
// Create a task and assigning it to the main assignee of the project Task task = platform.getTaskService().newTask("Obtain a copy of the police report", project.getMainAssignee().getUser());
// Relate the task to the project task.setProject(project);
// Set the due date based on the number of days specified in the rules parameter Calendar dueOn = Calendar.getInstance(); dueOn.setTime(project.getCreatedOn()); dueOn.add(Calendar.DAY_OF_YEAR, numberOfDaysAfter);
// Set the primary category of the task task.setPrimaryCategory("TASK_FLUP_FNOL"); } }); } } |
The following Java action uses multiple parameters. Based on these parameter values, the action creates a Package Request custom object record. It then determines whether to create a related history record based on a boolean parameter, and if so, creates the history record with the correct values.
Business Rule |
When the value in the Accident State custom field in a new Claim is New York, a letter Package Request project must be created to generate the appropriate notices for the insured and claimant. |
Action |
Create a Package Request with the following information: Requested for: Claim record. Parameter 1: Text field named "categories" and labeled "Type the full tree position of the Letter Package Request categories, separated by commas:" Parameter 2: Number field with the name "numberOfDaysAfter" and the label "Type the number of days from the moment the rule is triggered to specify the date when the letters must be sent out:" Parameter 3: Check Box field with the name "isAuditCreated" and the label "Specify whether an audit file should be created for each request:" Using Parameter 1, add the specified categories to the package request record. Send Date: Parameter 2. Create Audit File: Parameter 3. •If yes—create a history record with following data in its fields: Text: NY Package request generated. Default Category: Audit Parent: the Claim project. Entered by: TeamConnectAdmin. •If no—no other records are created. |
Sample Values |
Object Definition: Claim or any custom object definition Related Objects Created: PKRE (custom object Package Request) TNHistory (the audit file) Wizard Parameters: categories (Text) numberOfDaysAfter (Number) isAuditCreated (Check Box) Categories: PKRE (root category of Package Request) HIST_AUDI (History category) Custom Fields: In PKRE: requestedFor (custom field of type Custom Object, pointing to the same custom object definition as the one for which the rule is written) sendDate (Date) |
Java Parameterized Action: Creating Project with Related History Using Parameters
public class CreatingProjectWithRelatedHistory extends CustomAction<Project> {
@Override public void declareParameters() { parameters.addTextParameter("categories", "Full tree position of the Letter Package Request categories, separated by commas", null); parameters.addNumberParameter("numberOfDaysAfter", "Number of days between the rule triggering and the date the letters must be sent out", Long.valueOf(1)); parameters.addBooleanParameter("isAuditCreated", "Whether an audit file should be created for each package request", null); }
@Override public void action(final Project project) { // Get the parameter values final int numberOfDaysAfter = parameters.getNumberParameterValue("numberOfDaysAfter").intValue(); final boolean isAuditCreated = parameters.getBooleanParameterValue("isAuditCreated"); final String[] categories = parameters.getTextParameterValue("categories").split(Pattern.quote(","));
// Run as system user to bypass security platform.getUtilityService().runAsSystemUser(new Callable() { @Override public void call() { // Creating new package request Project packageRequest = platform.getProjectService().newProject("PKRE");
// Setting value of Requested For custom field to the current project object packageRequest.setProjectFieldValue("PKRE", "requestedFor", project);
for (String category : categories) { packageRequest.addCategory(category); }
Calendar sendDate = Calendar.getInstance(); sendDate.setTime(new Date()); sendDate.add(Calendar.DAY_OF_YEAR, numberOfDaysAfter); packageRequest.setDateFieldValue("PKRE", "sendDate", sendDate.getTime());
if (isAuditCreated) { // Create history with primary category set to audit History history = platform.getHistoryService().newHistory("Package request generated", project); history.setPrimaryCategory("HIST_AUDI"); } } }); } } |