You need to sign in to do that
Don't have an account?
Priyanka Bardhan
Filtering long text area fields in SOQL to compare with Set
Hi All,
Can anyone help on the below?
Since we can't use text area fields in SOQL filter criterias, the alternative approach is to fetch all records and then iterate (using for loop) to check filter criteria using below snippet.
List<Account> filteredaccounts = new List<Account>();
for(Account act : [select id, name, textareaids__c from Account) {
if(act.textareaids__c.contains('developer test')) {
filteredaccounts.add(act);
}
}
But how to do in case of comparing long text area with set of ids?
Example -
textareaids__c = 'id1, id2, id3, id5';
Set variable which contains id4, id5, id3.
Here I want to compare and match inside for loop to get the filtered accounts. Since we got a match of id3 and id5, store the account record in list.
Can anyone help on the below?
Since we can't use text area fields in SOQL filter criterias, the alternative approach is to fetch all records and then iterate (using for loop) to check filter criteria using below snippet.
List<Account> filteredaccounts = new List<Account>();
for(Account act : [select id, name, textareaids__c from Account) {
if(act.textareaids__c.contains('developer test')) {
filteredaccounts.add(act);
}
}
But how to do in case of comparing long text area with set of ids?
Example -
textareaids__c = 'id1, id2, id3, id5';
Set variable which contains id4, id5, id3.
Here I want to compare and match inside for loop to get the filtered accounts. Since we got a match of id3 and id5, store the account record in list.
For this, you need to use for inside for as your Text Area field contains multiple ids separated using a comma. Use code like below: Thanks,
Amit