+ Start a Discussion
sushieatersushieater 

batch update of knowledgeArticles

I am new to salesforce and have been implementing a public knowledge base. 

 

Is there anyway to batch update the channel that articles belong to? I have about 800 articles that I need to be added to the "Public Knowledge Base" channel. I'd like to avoid getting someone to manually go through them all if possible!

 

Thanks and Sorry if this is obvious. 

Best Answer chosen by Admin (Salesforce Developers) 
francoisLfrancoisL

Hi,

 

Sorry, but there is no Update API available right now on Knowldge. Full API will be available next year. 

All Answers

sushieatersushieater

Thanks for the point in the right direction!

 

I'm getting an error when trying to accomplish this. Below is my Batchable class.

 

 

 

global class knowledgeArticleBatchChanelSetter implements Database.Batchable<sObject>{

   global final String Query;


   global knowledgeArticleBatchChanelSetter(){
             query = 'SELECT title, IsVisibleInPkb FROM KnowledgeArticleVersion Where PublishStatus=\'Online\'' ;
   }

   global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, List<sObject> scope){
		for(Sobject s : scope){
			s.put('IsVisibleInPkb',true); 
      	}      
      	update scope;
   }

   global void finish(Database.BatchableContext BC){

   }


}

 

 

I'm running this in the system log app.

 

database.executeBatch(new knowledgeArticleBatchChanelSetter());

 

 

I see in the logs an error 

 

 

MALFORMED_QUERY: Implementation restriction: When querying or searching the KnowledgeArticleVersion 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.

 My query does have that filter clause and is valid, but when I look in the log, the,

Where PublishStatus=\'Online\'

 clause has been stripped out before SOQL execution. Am I supposed to be doing this differently somehow? Why does this query work normally?

 

 

 

Thanks!

 

 

francoisLfrancoisL

Hi,

 

Sorry, but there is no Update API available right now on Knowldge. Full API will be available next year. 

This was selected as the best answer
sushieatersushieater

thanks very much.