function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jimmy_sfjimmy_sf 

Knowledge Article soql problem

I've run across some odd knowledge article behavior.  My KnowledgeAticleVersion soql querys are not working with variable substitution:

 

// Fails with comile error 

String languageCode = 'es';

List<KnowledgeArticleVersion> foo = [select MasterVersionId, Title, Language from KnowledgeArticleVersion where PublishStatus = 'Draft' and Language =: languageCode and IsMasterLanguage = false] ;

 

// Works fine

List<KnowledgeArticleVersion> foo = [select MasterVersionId, Title, Language from KnowledgeArticleVersion where PublishStatus = 'Draft' and Language = 'es' and IsMasterLanguage = false] ;

 

Shouldn't the first example work? 

 

Best,

-james 

cloudmaniacloudmania

Try to put second and condition in the bracket...What kind of object is this?This must be standard.I have ever use it before:)

Navatar_DbSupNavatar_DbSup

 

Hi,


You are right first option should also work.
Try the below code as reference:
string st='abc';
list<contact>con=[select id from contact where lastname=:st];
system.debug('@@@@@@@@@@@@' + con.size());

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

jimmy_sfjimmy_sf

Navatar,

 

The code you've posted will work.  The variable sub issue is only occuring for me with KnowledgeAticleVersion objects, not Contacts.  

 

-jimmy 

Rune AndersenRune Andersen
Did you find a solution to setting the language parameter via a variable. I'm struggeling with the samme issue :-/