- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 01:03 AM
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?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 01:20 AM
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
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 02:15 AM
@Sweta1012 Create an on before update business rule with following configuration on your kb_knowledge table with following configuration.
Add following script in your business rule.
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 01:06 AM
@Sweta1012 How the article state would change to Draft state? Will it be done by the logged in user?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 01:11 AM - edited 07-28-2023 01:15 AM
Yes, by the logged in user. The logged in user will checkout the published article and it will be changed to draft

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 02:15 AM
@Sweta1012 Create an on before update business rule with following configuration on your kb_knowledge table with following configuration.
Add following script in your business rule.
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 01:20 AM
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
Harish