0

I have the following code:

List<KnowledgeArticleVersion> articles = [SELECT Title, UrlName, FirstPublishedDate, Summary, ArticleType, LastModifiedDate
                    FROM KnowledgeArticleVersion
                    WHERE isVisibleInApp=:isInternal AND isVisibleInCsp=:isCustomer AND isVisibleInPkb=:isPublic
                    AND IsVisibleInPrm=:isPartner AND PublishStatus='Online' AND Language=:selectedLanguage];
System.debug('articles = ' + articles);

and I certainly fetch error:

Error 4 Implementation restriction:

When querying the KnowledgeArticleVersion object, you must filter using the following syntax: Id = [single ID], Id IN [list of ID's] or Language = [language ISO code]. In addition Language is only permitted in a top-level AND condition.

But after replacing var selectedLanguage on 'en_US' soql works fine.

List<KnowledgeArticleVersion> articles = [SELECT Title, UrlName, FirstPublishedDate, Summary, ArticleType, LastModifiedDate
                    FROM KnowledgeArticleVersion
                    WHERE isVisibleInApp=:isInternal AND isVisibleInCsp=:isCustomer AND isVisibleInPkb=:isPublic
                    AND IsVisibleInPrm=:isPartner AND PublishStatus='Online' AND Language='en_US'];
                    System.debug('articles = ' + articles);

Really I can`t select articles with dynamic lang?

1 Answer 1

0

yes, you can select articles dynamically, you need to use dynamic soql.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_soql.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .