Knowledge Versioning by script

iagruthijonnaga
Giga Contributor

Hi All,

 

I Have knowledge version plugin enabled, to create knowledge version we basically use OOB UI action, but now that need is, i have a condition to retire an article and now once the article gets retired versioning need to be created automatically with out clicking UI action.

Needed help on how this can be implemented.

 

 

Thanks 

Jagruthi.J 

1 ACCEPTED SOLUTION

Hi Sachin,

 

Thanks

But i achieved it through schedule job based on some other field date, using the same script as of checkout ui action by calling the script include.

 worked like this.

 

var dt = new GlideDate();
dt.getByFormat("MM-dd-yyyy");
var tb = new GlideRecord('kb_knowledge');
tb.addQuery('workflow_state', 'published');
tb.addQuery('published', dt);
tb.query();
while(tb.next()){
var newRecord = new KBVersioning().checkout(tb);
gs.log("newRecord:"+newRecord);
if(newRecord){
gs.addInfoMessage(gs.getMessage("A new version of the article is created for revision."));
//action.setRedirectURL(newRecord);
tb.update();
}
else
gs.addErrorMessage(gs.getMessage("You cannot checkout this article as it is already checked out."));

}

Regards,

Jagruthi.J

 

View solution in original post

6 REPLIES 6

ergh. I dont know if you misunderstand me. But to be clear.

 

1. When retiring a article, there isn't a new version being created. There isn't any reason for this

2. Minor revsions doesn't create new versions. I think it's a flaw, but once it's in draft or you specified specific fields you can update without checkout, you keep the same version. Try edit a draft document multiple times and you see it kept the same version.

 

And yes, I'm still questioning the reason for having a new version when you retire. Not just give a script that has the solution and might not be a good way in the bigger picture or for the future.

Hi Sachin,

 

Thanks

But i achieved it through schedule job based on some other field date, using the same script as of checkout ui action by calling the script include.

 worked like this.

 

var dt = new GlideDate();
dt.getByFormat("MM-dd-yyyy");
var tb = new GlideRecord('kb_knowledge');
tb.addQuery('workflow_state', 'published');
tb.addQuery('published', dt);
tb.query();
while(tb.next()){
var newRecord = new KBVersioning().checkout(tb);
gs.log("newRecord:"+newRecord);
if(newRecord){
gs.addInfoMessage(gs.getMessage("A new version of the article is created for revision."));
//action.setRedirectURL(newRecord);
tb.update();
}
else
gs.addErrorMessage(gs.getMessage("You cannot checkout this article as it is already checked out."));

}

Regards,

Jagruthi.J