Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
LoadFormData Class
Namespace
Example
Use methods in the LoadFormData class to set available and selected values in different form components:
1List<System.SelectOption> picklistOptions = new List<System.SelectOption>();
2picklistOptions.add(new System.SelectOption('optIn', 'Opt In'));
3picklistOptions.add(new System.SelectOption('optOut', 'Opt Out'));
4
5// Set the available options for the picklist
6loadFormData.setOptions('myPicklist', picklistOptions);
7// Add an option to the existing options for the picklist
8loadFormData.addOption('myPicklist', 'optOutAll', 'Opt Out All');
9// Select the 'optIn' option in the picklist
10loadFormData.setSelectedOption('myPicklist', 'optIn');
11
12
13List<System.SelectOption> checkboxOptions = new List<System.SelectOption>();
14checkboxOptions.add(new System.SelectOption('yes', 'Yes'));
15checkboxOptions.add(new System.SelectOption('no', 'No'));
16
17
18// Set available options for the checkbox group
19loadFormData.setOptions('myCheckbox', checkboxOptions);
20// Select the 'yes' option in the checkbox group
21loadFormData.addSelectedOption('myCheckbox', 'yes');
22// Also select the 'no' option in the checkbox group
23loadFormData.addSelectedOption('myCheckbox', 'no');
24// Another way to select both the 'yes' and 'no' options in the checkbox group
25loadFormData.setSelectedOptions('myCheckbox', new List<String>{'yes', 'no'});
26
27
28// Fill the value in the text input
29loadFormData.setTextValue('myTextInput', 'admin@salesforce.com');
30// Set the hint text for the text input
31loadFormData.setTextHint('myTextInput', 'Email Address');
32
33
34// Set the label for the button
35loadFormData.setButtonLabel('myButton', 'Save Preferences');LoadFormData Constructors
The following are constructors for LoadFormData.
LoadFormData(data)
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)
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)
Signature
public void setSelectedOptions(String fieldId, List<String> options)
Parameters
Return Value
Type: void