Show/Hide Toolbars

Parameters in actions and qualifiers are values that the Java file displays as fields in the user interface, as shown in the following image.

Parameters Added from an Automated Action

Parameters Added from an Automated Action

If values in a qualifier or an action might change, use parameters so that the solution developer can change the value without modifying the action or qualifier file. In addition, when you use parameters in rules, you are sometimes able to use the same file for multiple rules that require different values.

For example, when an automated action creates a task with the due date based on a date in a project, the solution developer can set the number of days before the task is due through the user interface. You can also use an automated action to create new accounts for budgets that a solution developer sets from a parameter.

Set or get parameter values using the methods from the Parameters class.

For code samples, see Parameterized Actions.

About Parameters in Wizards

Wizard page actions use the following types of parameters:

Wizard parameters that are transient values of different types that the wizard creates, uses, and discards afterwards. The user who designs the wizard through the user interface defines the wizard parameter name within the wizard.

All sub-objects and related objects defined in the template, which the wizard treats as parameters. The system within the template automatically defines the names of these parameters, using the name of the object and a sequential number. For example, Account 1, History 1, Assignee 1, and Assignee 2.

Parameters that you use in any automated action or qualifier.

Adding and Using Parameters

Qualifiers and actions both accept parameters. Parameters are fields that appear on the Qualifier, General, and Action pages that someone working in the Setup can update. When adding, getting, or setting parameters, use the Parameters class.

You define parameters in rules in the following way:

The CustomCondition.declareParameters() or CustomAction.declareParameters() methods, which accept methods from the Parameters class.

The add methods in the Parameters class, which create the parameters. The class includes a parameter for each data type and certain system objects. For example, if you want to add a project field to the Qualifier or Action page, use the addProjectParameter() method.

After you define parameters, you include the code for the qualifier or action using the condition(M) or action(M) methods. As part of this code, you can retrieve the value entered for a parameter in the Setup. In the case of the project parameter example, you use the getProjectParameterValue() method to retrieve the project. If you need to update the value an existing parameter within the condition(M) or action(M) methods, you can use the set methods. For example, setProjectParameterValue().

If no one enters a value for the parameter, the qualifier or action uses the default value for the parameter. When someone enters a value in the Setup for the parameter field, the entered value overrides the default value.

The following code sample demonstrates how to add parameters to the Action page of a rule. The action code retrieves the value of the parameter text field with the name "text" and updates the name of a project with the value.

public class TestRuleAction extends CustomAction<Project> {

 

@Override

public void declareParameters() {

parameters.addTextParameter("text", "Text", "default value");

parameters.addPasswordParameter("password", "Password", "default password");

parameters.addBooleanParameter("action boolean", "action boolean", false);

Date date = new Date();

parameters.addDateParameter("new action date", "new action date", new Date());

parameters.addDecimalParameter("action decimal", "action decimal", BigDecimal.valueOf(.5));

parameters.addNumberParameter("action number", "action number", Long.valueOf(5));

parameters.addMemoParameter("action memo", "action memo", "This is memo text field content");

Account account = platform.getAccountService().read(Long.valueOf(503));

addAccountParameter("action account", "action account", account);

}

 

@Override

public void action(final Project dispute) {

dispute.setName(parameters.getTextParameterValue("text"));

Account newAccount = platform.getAccountService().newAccount("Test Account", BigDecimal.valueOf(1000), new Date(), new Date());

newAccount.setNote("Here is a note that has been set");

}

}