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?

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

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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