The CreatorCon Call for Content is officially open! Get started here.

Knowledge management

Sweta1012
Tera Contributor

When a user checks out a published article (for which the user is not the author) in knowledge management and it goes to the draft state, the author field should auto populate to the logged-in user. How to achieve it through scripting?

2 ACCEPTED SOLUTIONS

Harish KM
Kilo Patron
Kilo Patron

Hi there are 2 ways to do this, you can modify the UI action checkout like below or you need to modify the scriptinclude which is getting called in checkout UI Action

script:

current.author = gs.getUserID(); // set loggedin user ID to author
current.update(); // update the record

HarishKM_0-1690532374193.png

 

Regards
Harish

View solution in original post

@Sweta1012 Create an on before update business rule with following configuration on your kb_knowledge table with following configuration.

 

Screenshot 2023-07-28 at 2.39.54 PM.png

Add following script in your business rule.

Screenshot 2023-07-28 at 2.42.55 PM.png

Here is the script.

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	if(!current.author){
		current.author=gs.getUserID();
	}

})(current, previous);

Hope this helps.

View solution in original post

4 REPLIES 4

Sandeep Rajput
Tera Patron
Tera Patron

@Sweta1012 How the article state would change to Draft state? Will it be done by the logged in user?

Yes, by the logged in user. The logged in user will checkout the published article and it will be changed to draft

@Sweta1012 Create an on before update business rule with following configuration on your kb_knowledge table with following configuration.

 

Screenshot 2023-07-28 at 2.39.54 PM.png

Add following script in your business rule.

Screenshot 2023-07-28 at 2.42.55 PM.png

Here is the script.

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	if(!current.author){
		current.author=gs.getUserID();
	}

})(current, previous);

Hope this helps.

Harish KM
Kilo Patron
Kilo Patron

Hi there are 2 ways to do this, you can modify the UI action checkout like below or you need to modify the scriptinclude which is getting called in checkout UI Action

script:

current.author = gs.getUserID(); // set loggedin user ID to author
current.update(); // update the record

HarishKM_0-1690532374193.png

 

Regards
Harish