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
Rune AndersenRune Andersen 

KnowledgeArticleVersion language paramater as a variable?

I have the following query that works fine, no problems
[SELECT Id FROM KnowledgeArticleVersion WHERE (PublishStatus = 'online' and ArticleNumber=:articleNo and Language = 'en_US')];

It is used to find article id's from articlenumbers.
Now I would like to expand the query to support variable languages so
[SELECT Id FROM KnowledgeArticleVersion WHERE (PublishStatus = 'online' and ArticleNumber=:articleNo and Language = :artLanguage)];

This one is not accepted by the compiler as it violates some restriction to querying the KnowledgeArticleVersion.
Does any one know how to work around this limitation without having to copy and perform a query for each language supported by the Knowledgebase on the current system?

- Regards
Praveen PosaPraveen Posa
 if your knowledge base supports multiple languages, try this

  [SELECT Id FROM KnowledgeArticleVersion WHERE (PublishStatus = 'online' and ArticleNumber=:articleNo and Language = : art.MasterLanguage)];

 
Rune AndersenRune Andersen
Thanks for the reply.
I don't see how this solves my problem. what is the art variable that you're using?
Rune AndersenRune Andersen
As ekstra details to the original post:

The second select statement with declared variable
String artLanguage = 'en_US';
[SELECT Id FROM KnowledgeArticleVersion WHERE (PublishStatus = 'online' and ArticleNumber=:articleNo and Language = :artLanguage)];

If it is possible I would be happy to leave out the language part of the select statement, but it doesn't seem like Salesforce support this, any good explanations as to why this restrictions apply?