0

I am trying to fetch record in my trigger using SOQL using LIKE. The value I need to compare is a combination of three fields. I am trying the below code. Not sure what I am doing wrong

string DocName = ''+q.SBQQ__Account__c+' - '+q.SBQQ__Account__c+' - '+q.Name+'%';
Document d = [Select id from Document where Name LIKE ''+DocName+'' order by CreatedDate asc LIMIT 1];
  • what is the error? p.s. there are a lot of questions on dynamic SOQL - this is most likely to be closed as a duplicate. – glls Sep 22 '17 at 3:26
  • @SantanuBoral Not exactly, the string I want to compare is a combination of the three fields. For example my string to compare would be Account - Account - Name – Afroz Kazi Sep 22 '17 at 4:53
2

This query isn't even dynamic SOQL. You just use bind syntax:

WHERE Name LIKE :docName
|improve this answer|||||
0

Hope your looking for this

string DocName ='\'' + q.SBQQ__Account__c +' - '+ q.SBQQ__Account__c + ' - '+ q.Name+'%\'';
Document d = [Select id from Document where Name LIKE :DocName order by CreatedDate asc LIMIT 1];
|improve this answer|||||

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