+ Start a Discussion
kevindotcarkevindotcar 

Language error with knowledgebase article query

Sorry, I cross-posted this in the General forum.

 

I'm trying to run the following code in a controller:

 

public ApexPages.StandardSetController con {
        get {
            if(con == null) {
               con = new ApexPages.StandardSetController([SELECT Id, Title FROM Answer__kav

                        WHERE  (PublishStatus = 'Online' AND Language = 'en_US') ])
                con.setPageSize(15);   // sets the number of records in each page set
                }
            return con;
            }
        set;
    }

 

When I call the method, I get

MALFORMED_QUERY: Implementation restriction: When querying or searching the Answer__kav object, you must filter using the following syntax: Id = [single ID], Id IN [list of ID's] or PublishStatus = [status]. In addition PublishStatus is only permitted in a top-level AND condition.

 

... but it runs just fine in SOQL explorer.

 

Anyone see anything that I'm missing?  I also tried the query in the workbench and it ran just fine.

 

Thanks in advance,


Andy BoettcherAndy Boettcher

Take your parenthesis away after the WHERE part of your SOQL statement.  Parenthesis are only required if you're grouping certain conditionals together.  You do not have any seperate conditionals, so just drop them.

 

-Andy

Gopinath.AGopinath.A

Hi,

 

 This is my code  pagination  for Knowledgebase artcle query using Wrapperclass.

 

public ApexPages.StandardSetController con1 {
  get {

       kwArtId = new Set<Id>();
       String title=System.currentPagereference().getParameters().get('Title');
       System.debug('Incoming title::'+title);
       List<Book__DataCategorySelection> datacategoryid=[select id,parentid,DataCategoryName from          Book__DataCategorySelection];
       system.debug('#datacategoryid List : '+datacategoryid);
       for(Book__DataCategorySelection dataid:datacategoryid){
        System.debug('Input page'+dataid.DataCategoryName);
        if('Fiction'.equals(dataid.DataCategoryName)){
       kwArtId.add(dataid.parentid);
       }
      System.debug('Parent id is::'+dataid.parentid);
}


if(con1 == null) {
con1 = new ApexPages.StandardSetController(Database.getQueryLocator([Select id, ArticleNumber,publish_date__c, UrlName, Title,Summary, Subject__c, PublishStatus,
OwnerId, LastPublishedDate, LastModifiedDate, LastModifiedById, KnowledgeArticleId, FirstPublishedDate,
Files_to_attach__Name__s, Files_to_attach__Length__s, Files_to_attach__ContentType__s,
Description__c, CreatedDate, CreatedById, Author__c, ArchivedDate, ArchivedById
From Book__kav where PublishStatus = 'Online' AND Language = 'en_US' AND Id in : kwArtId]));
// sets the number of records in each page set
System.debug('###### con1 has ######'+con1);
con1.setPageSize(3);
}
return con1;
}
set;
}

public List<categoryWrapper> getCategories() {
categories = new List<categoryWrapper>();

for (Book__kav category : (List<Book__kav>)con.getRecords())
categories.add(new CategoryWrapper(category));

return categories;
}

 

 

I am getting this error...........when trying to pagination using wrapperclass.

 

MALFORMED_QUERY: Implementation restriction: When querying or searching the Book__kav object, you must filter using the following syntax: Id = [single ID], Id IN [list of ID's] or PublishStatus = [status]. In addition PublishStatus is only permitted in a top-level AND condition. 

 

 Thanks,

Gopinath