Hi All,
We might have come across a scenario to filter some record based on a field value which is long text area type.This is post is all about how can we filter records using text area field value.
Here is code:-
String s;
list<Account> listOfAccounts = [SELECT id,name FROM Account WHERE TextAreaFiedl__c like :'%'+s+'%'];
If we write same code then compiler will fire a error like below image.
Below is work around for above error.
String s = 'asish';
list<Account> listOfAccounts;
listOfAccounts = new list<Account>();
for(Account acc:[SELECT id,name,TextAreaFiedl__c FROM Account where name='test']){
if(acc.TextAreaFiedl__c.Contains(s)){
listOfAccounts.add(acc);
}
}
We might have come across a scenario to filter some record based on a field value which is long text area type.This is post is all about how can we filter records using text area field value.
Here is code:-
String s;
list<Account> listOfAccounts = [SELECT id,name FROM Account WHERE TextAreaFiedl__c like :'%'+s+'%'];
If we write same code then compiler will fire a error like below image.
Below is work around for above error.
String s = 'asish';
list<Account> listOfAccounts;
listOfAccounts = new list<Account>();
for(Account acc:[SELECT id,name,TextAreaFiedl__c FROM Account where name='test']){
if(acc.TextAreaFiedl__c.Contains(s)){
listOfAccounts.add(acc);
}
}
No comments:
Post a Comment