Allow Author of KB to checkout article

Dawid2
Giga Guru

We have OOB author field on the KB Article form.

If article is in published state, author should be able to checkout for a new version. I've added condition to the UI Action "Checkout" current.workflow_state == 'published' && current.author == gs.getUserID()

And while author can see the button, upon clicking it it says You cannot checkout this article as it is already checked out.

This author has itil role and does not have any knowledge related roles (that's the main idea here).

How can this be achieved?

1 ACCEPTED SOLUTION

Dawid2
Giga Guru
Okay, I figured it out.
 
There is script include called KBVersioningSNC that controls behavior of different functions like canContribute or canCheckout.
 
Since it's read only, I had to override it in KBVersioning script include by modifying canCheckout function with line:
if(current.author==gs.getUserID())
return true;
 
And it works.

View solution in original post

5 REPLIES 5

Hi Yogita,

 

It's been few years and I can't remember correctly, but as far as I'm concerned KBVersioningSNC is never being called directly, that's why you need override a function of your choice in KBVersioning script include. Check out a snippet of the code and adjust it to your needs:

 

canCheckout: function(current){	
		if(gs.getProperty('glide.knowman.allow_edit_global_articles')=='false' && this.isArticleReadOnlyBasedOnDomain(current))
			return false;
		if(this.isExternalArticle(current))
			return false;
		if(!this._isValidVersion(current))
			return false;
		if(current.workflow_state!=this.MAJOR_STATE)
			return false;
		if(current.author==gs.getUserID())
			return true;
		if(current.u_owner==gs.getUserID())
			return true;
		//If Ownership Group exist but user is not a member
		if(this.isValidFieldWithValue(current,this.OWNERSHIP_GROUP)){
			if(!this.hasAnyElevatedAccess(current) && !this.isGroupMemberOrManager(current[this.OWNERSHIP_GROUP]))
				return false;
		}else if(!this.hasAnyElevatedAccess(current) && !this.safeExecute(this._knowledgeHelper.canContribute, current))
			return false;
		if(this._getCheckedoutRecord(current))
			return false;
		return true;
	},