For the External Select component, construct your data using List<Slack.Option> and return it using Slack.OptionDataResponse.
Alternatively, specify the values or use an expression in the view definition for the Select or External Select component.
Usage
Construct List<Slack.Option> to build a list of values for the Select component.
1public class DataProviderOpportunityLookup{2 private static final String NO_OPPORTUNITY = 'Account has no Opportunity';3 private static final String MISSING_OR_INCORRECT_ACCOUNT_ID = 'Account Id is missing or is incorrect';45 /* Use List<Slack.Option> to retrieve all opportunities by accountId.6 Return result in the format List<String, String> to the view. */7 public static List<Slack.Option>getOpportunitiesByAccount(String accountId){8 List<Slack.Option>oppOptions;910 if(String.isNotBlank(accountId)){11 List<Opportunity>opps = queryOpportunities(accountId);12 oppOptions = new List<Slack.Option>();1314 if(!opps.isEmpty()){15 for(Opportunity opp : opps){16 Slack.Option oppOption = new Slack.Option(opp.Name, opp.Id);17 oppOptions.add(oppOption);18}19}else{20 oppOptions.add(new Slack.Option(NO_OPPORTUNITY, NO_OPPORTUNITY));21}22}else{23 oppOptions = new List<Slack.Option>{new Slack.Option(MISSING_OR_INCORRECT_ACCOUNT_ID, MISSING_OR_INCORRECT_ACCOUNT_ID)};24 System.debug(MISSING_OR_INCORRECT_ACCOUNT_ID);25}2627 return oppOptions;28}29}
Alternatively, use the Slack.Option class to build your option list for the External Select component and return it using Slack.OptionDataResponse.
1public class DataProviderAccountLookup{2 public static Slack.OptionDataResponse getAccountsByName(String value){3 List<Account>accounts;4 if(String.isNotBlank(value)){5 String name = '%' + value + '%';6 accounts = [SELECT Id, Name FROM Account WHERE Name LIKE :name WITH SECURITY_ENFORCED LIMIT 10];7}89 List<Slack.Option>accountOptions = new List<Slack.Option>();10 if(accounts != null){11 for(Account account : accounts){12 Slack.Option option = new Slack.Option(account.Name, account.Id);13 accountOptions.add(option);14}15}16 return new Slack.OptionDataResponse(accountOptions);17}18}
Option Constructor
Option has the following constructor.
Option(text, value)
Creates an instance of the Slack.Option class with the text and value.
Signature
1public Option(String text, String value)
Parameters
text
Type: String
The text to display on the component.
value
Type: String
The value of the option.
Option Methods
The following are methods for Option.
getText()
Gets the display text for the component.
Signature
1public String getText()
Return Type
Type: String
getValue()
Gets the value of the option.
Signature
1public String getValue()
Return Type
Type: String
OptionDataResponse Class
The data to return for the External Select component using a List<Slack.Option> or List<Slack.OptionGroup>.
Usage
Construct Slack.OptionDataResponse with List<Slack.OptionGroup> or List<Slack.Option>.
Constructing a Slack.OptionDataResponse with a combination of Slack.Option and Slack.OptionGroup isn’t supported. If both are present in the Slack.OptionDataResponse, the UI doesn’t update.
Important
OptionDataResponse Constructors
The following are constructors for OptionDataResponse.
Alternatively, construct your data using List<Slack.OptionGroup> for the Select component.
1public class DataProviderOpportunityLookup{2 private static final String NO_OPPORTUNITY = 'Account has no Opportunity';3 private static final String MISSING_OR_INCORRECT_ACCOUNT_ID = 'Account Id is missing or is incorrect';45 public static List<Slack.OptionGroup>getOpportunitiesByStage(String accountId){6 List<Slack.OptionGroup>opportunityOptionGroup;78 if(String.isNotBlank(accountId)){9 List<Opportunity>opportunities = queryOpportunities(accountId);10 opportunityOptionGroup = new List<Slack.OptionGroup>();1112 if(!opportunities.isEmpty()){13 List<Slack.Option>newOptions = new List<Slack.Option>();14 List<Slack.Option>inProgressOptions = new List<Slack.Option>();15 List<Slack.Option>closedOptions = new List<Slack.Option>();1617 for(Opportunity opp : opportunities){18 switch on opp.StageName{19 when 'New'{20 Slack.Option newOption = new Slack.Option(opp.Id, opp.Name);21 newOptions.add(newOption);22}23 when 'In Progress'{24 Slack.Option inProgressOption = new Slack.Option(opp.Id, opp.Name);25 inProgressOptions.add(inProgressOption);26}27 when 'Closed'{28 Slack.Option closedOption = new Slack.Option(opp.Id, opp.Name);29 closedOptions.add(closedOption);30}31}32}3334 Slack.OptionGroup newOptionGroup = new Slack.OptionGroup('New Opportunities', newOptions);35 opportunityOptionGroup.add(newOptionGroup);36 Slack.OptionGroup inProgressOptionGroup = new Slack.OptionGroup('In Progress Opportunities', inProgressOptions);37 opportunityOptionGroup.add(inProgressOptionGroup);38 Slack.OptionGroup closedOptionGroup = new Slack.OptionGroup('Closed Opportunities', closedOptions);39 opportunityOptionGroup.add(closedOptionGroup);40}else{41 opportunityOptionGroup.add(getEmptyOptionGroup());42}43}else{44 opportunityOptionGroup.add(getEmptyOptionGroup());45 System.debug(MISSING_OR_INCORRECT_ACCOUNT_ID);46}4748 return opportunityOptionGroup;49}50}
This feature is not generally available. It is not part of your purchased Services. This feature is subject to change, may be discontinued with no notice at any time in SFDC’s sole discretion, and SFDC may never make this feature generally available. Make your purchase decisions only on the basis of generally available products and features. This feature is made available on an AS IS basis and use of this feature is at your sole risk.