2

In SOSL can I add a variable to the fields? As:

FIND {Clinica} IN Name Fields RETURNING Account(VARIABLE HERE)

Thanks

3

Dynamic SOSL is what you need.

List<String> fields = new List<String> { 'Name' };
String term = 'FIND \'Clinica\' IN Name Fields RETURNING Account (' + String.join(fields, ',') + ')';
  • Thanks, Adrian! if i need more than 1 field do i separate with comma? – Diego Edargo Pessoa Nov 13 '19 at 16:56
  • Yes, multiple elements would look like: new List<String> { 'a', 'b', 'c', 'etc.' };. – Adrian Larson Nov 13 '19 at 16:56
  • Thank you so much! – Diego Edargo Pessoa Nov 13 '19 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.