1

I have Set in my apex class as below

 Set<String> removeFields = new Set<String>{'isUpage','email','mobileno','owneremail','comments','Name','isApproved'}; 

I need to use these strings as custom settings because in future if i need to add any string to this list i can go through configuration instead of touching apex class

can anyone suggest me how to creates and get that custom setting values into set.

2 Answers 2

2

You could simply create a list custom setting (for example with API name CustomSettingName__c) and enter the values in standard Name field. The name field is also unique which does not allow a duplicate value.

Map<String, CustomSettingName__c> mcs = CustomSettingName__c.getAll(); Set<String> removeFields = mcs.keySet(); 
1

You can create a List Custom Setting or can use Custom Metadata and have all the values as records. Then when fetching the records, you can get the records from custom settings/custom metadata and convert those records into a set<string>

If you store these values as records in custom settings, where your name field will contain the value of string, then you can get those values as set directly using below method

Map<String, StringValues__c> stringValues = StringValues__c.getAll(); Set<String> removeFields = stringValues.keyset(); 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.