Namespace
Example
Use methods in the LoadFormData class to set available and selected values in different form components:
List<System.SelectOption> picklistOptions = new List<System.SelectOption>(); picklistOptions.add(new System.SelectOption('optIn', 'Opt In')); picklistOptions.add(new System.SelectOption('optOut', 'Opt Out')); // Set the available options for the picklist loadFormData.setOptions('myPicklist', picklistOptions); // Add an option to the existing options for the picklist loadFormData.addOption('myPicklist', 'optOutAll', 'Opt Out All'); // Select the 'optIn' option in the picklist loadFormData.setSelectedOption('myPicklist', 'optIn'); List<System.SelectOption> checkboxOptions = new List<System.SelectOption>(); checkboxOptions.add(new System.SelectOption('yes', 'Yes')); checkboxOptions.add(new System.SelectOption('no', 'No')); // Set available options for the checkbox group loadFormData.setOptions('myCheckbox', checkboxOptions); // Select the 'yes' option in the checkbox group loadFormData.addSelectedOption('myCheckbox', 'yes'); // Also select the 'no' option in the checkbox group loadFormData.addSelectedOption('myCheckbox', 'no'); // Another way to select both the 'yes' and 'no' options in the checkbox group loadFormData.setSelectedOptions('myCheckbox', new List<String>{'yes', 'no'}); // Fill the value in the text input loadFormData.setTextValue('myTextInput', 'admin@salesforce.com'); // Set the hint text for the text input loadFormData.setTextHint('myTextInput', 'Email Address'); // Set the label for the button loadFormData.setButtonLabel('myButton', 'Save Preferences');
LoadFormData Constructors
The following are constructors for LoadFormData.
LoadFormData(data)
Creates an instance of the LoadFormData class for running tests on any custom Apex classes you create for
Preference Manager.
Signature
public LoadFormData(Map<String,pref_center.FieldProperties> data)
Parameters
- data: Type: Map<String,pref_center.FieldProperties>Map Maps preference form data from the field ID to the field properties.
Usage
This constructor is available in API version 56.0 and later.
LoadFormData Methods
The following are methods for LoadFormData.
addOption(fieldId, value, label)
addOption(fieldId, option)
Add a defined, selectable option for a checkbox, picklist, or radio
button field in a preference form.
Signature
public void addOption(String fieldId, System.SelectOption option)
Parameters
- fieldId: Type: String Identifies a field in the preference form.
- option: Type: System.SelectOption The option selected on a field in the preference form.
Return Value
Type: void
addSelectedOption(fieldId, option)
setOptions(fieldId, options)
Signature
public void setOptions(String fieldId, List<System.SelectOption> options)
Parameters
- fieldId: Type: String Identifies a field in the preference form.
- options: Type: List<System.SelectOption> The selectable options for a field in the preference form.
Return Value
Type: void
setSelectedOption(fieldId, optionValue)
setSelectedOptions(fieldId, options)
For an existing checkbox field on a preference form that has defined
values, set the values entered in the options field as the selected options. This requires the
field on the form to have defined options with a set value.
Signature
public void setSelectedOptions(String fieldId, List<String> options)
Parameters
Return Value
Type: void