You need to sign in to do that
Don't have an account?
KbManagement.PublishingService.publishArticle() & Database.Batchable Class = FATALERROR.
I have an issue with the v25.0 . I am trying to test one of the new functionality that was release in v25.0. " KbManagement.PublishingService.publishArticle(KnowledgeArticleId, true)"
This is suppose to allow you programmatically publish an KnowledgeArticle that is in draft status. I wrote a simple class to test this functionality and it worked fine but I have about 120000 records to process to I figure I write a batchable class(seen below).
// // (c) 2012 Appirio, Inc. // // Description: This class implements the batchable interface and is used to publish KnowledgeArticles in draft Status // // global with sharing class PublishKnowledgeArticlesBatchClass implements Database.Batchable <sObject>{
global Database.QueryLocator start(Database.BatchableContext BC){ //String should be modifed depending on the number of records that the Publish Service can support String query = 'SELECT Title, Id, KnowledgeArticleId, PublishStatus, VersionNumber ' + ' FROM KnowledgeArticleVersion ' + ' WHERE PublishStatus =\'Draft\' ' + ' AND language =\'en_US\' AND LastModifiedDate =TODAY LIMIT 5'; return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<KnowledgeArticleVersion> scope){ //Call the PublishService with the id of each KnowledgeArticleId for(KnowledgeArticleVersion s : scope){ KbManagement.PublishingService.publishArticle(s.KnowledgeArticleId, true); }
}
global void finish(Database.BatchableContext BC){
} } |
However when i run the batch process, this is the response I get in the log.
25.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
09:50:00.144 (144586000)|EXECUTION_STARTED
09:50:00.144(144629000)|CODE_UNIT_STARTED[EXTERNAL]|01pQ00000001y9b|PublishKnowledgeArticlesBatchClass
09:50:00.164 (164988000)|FATAL_ERROR|Internal Salesforce.com Error
09:50:00.096 (165018000)|CUMULATIVE_LIMIT_USAGE
09:50:00.096|CUMULATIVE_LIMIT_USAGE_END
09:50:00.169 (169593000)|CODE_UNIT_FINISHED|PublishKnowledgeArticlesBatchClass
09:50:00.169 (169604000)|EXECUTION_FINISHED
Please any assistance will be greatly appreciated.
Regards
-H
Everything looks OK to me.
Now, did you try running each method in anonymous apex instead of kick starting an apex job? You would have more information about where is the crash actually happening.
Hello Henry,
Sorry, I cannot help you with your qustion, but you may be able help me with this simpler problem you seem to have solved already.
I am trying to publish & unpublish a single article via a apex webservice class, and have a test method. The 'test' goes through and succeeds but nothing happens. That is, the articles in question do NOT get published or unpublished. Any ideas? From your code it looks like you are doing the same thing really.
Here is my code. See any issues? Are the 'test' methods NOT supposed to make any changes to data or something, so it sets everything back to the original status before finishing? Thanks for any insights.
global Class webServiceKnowledge {
webService static Id unpublishArticle (String articleId) {
String idKav = kbManagement.PublishingService.editOnlineArticle (articleId,true) ;
return idKav ;
}
webService static void publishArticle (String articleId) {
KbManagement.PublishingService.publishArticle (articleId, true) ;
}
static testMethod void wskPublish () {
String knowledgeArticleId = '......' ;
String useId = knowledgeArticleId ;
system.debug(useId) ;
webServiceKnowledge.publishArticle(useId) ;
system.debug('Finished Publishing') ;
}
static testMethod void wskUnPublish () {
String knowledgeArticleId = '.....' ;
String useId = knowledgeArticleId ;
system.debug(useId) ;
String draftId = webServiceKnowledge.unpublishArticle(useId) ;
system.debug(draftId) ;
system.debug('Finished UnPublishing') ;
}
}
Hey guys, did any of you managed to solve those issues and could share the solution? I am facing similar problems.
Thanks!