- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 08:48 AM
Hello, we are exploring the idea of changing our knowledge articles so that only the article's author can edit their articles (and Knowledge Managers, etc). Has anyone done this before? If so, how did you restrict specific article edit access to the author?
I do see the arguments against changing this also though, as it could affect collaboration and complicate processes unnecessarily.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 03:30 AM
Hi @DylanB ,
Sure, I can't share the exact code, but I can share a different approach, using Business Rules and onLoad Client script. Follow along,
1. Business Rule: To prevent update of article from backend if the user is not the author, create a business rule like the one below.
2. Display Business Rule: To make the author of the article available to onLoad Client Script, Write a display business rule like the one below and use g_scratchpad to set the author.
3. onLoad Client Script: To disable the article fields for editing, write a client script like the one below.
function onLoad() {
if (g_form.isNewRecord()) {
return;
}
if(g_scratchpad.kb_author_name != g_user.userID){
g_form.addErrorMessage('You are not the author of this article.');
g_form.setReadOnly('text', true);
g_form.setReadOnly('short_description', true);
}
}
That's it!!!
Please Accept my Answer as Solution, if it helped in solving your issue.
Thanks,
Anvesh
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 09:52 AM
Hi @DylanB,
Recently we did similar one using a Before Update Business rule. We just check if the current user is not the actual author Abort the action and display the error message.
And, an onLoad client script which will call a Client Callable script include using GlideAjax to check if the current user is the actual author or not and and display a message saying the same and disable the fields for editing.
So we are restricting both ways, front end and backend.
Let me know if you need any more inputs for this approach.
Thanks,
Anvesh
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 12:52 PM
Hi Anvesh, would you be willing to share the scripts you're using for that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 03:30 AM
Hi @DylanB ,
Sure, I can't share the exact code, but I can share a different approach, using Business Rules and onLoad Client script. Follow along,
1. Business Rule: To prevent update of article from backend if the user is not the author, create a business rule like the one below.
2. Display Business Rule: To make the author of the article available to onLoad Client Script, Write a display business rule like the one below and use g_scratchpad to set the author.
3. onLoad Client Script: To disable the article fields for editing, write a client script like the one below.
function onLoad() {
if (g_form.isNewRecord()) {
return;
}
if(g_scratchpad.kb_author_name != g_user.userID){
g_form.addErrorMessage('You are not the author of this article.');
g_form.setReadOnly('text', true);
g_form.setReadOnly('short_description', true);
}
}
That's it!!!
Please Accept my Answer as Solution, if it helped in solving your issue.
Thanks,
Anvesh
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2023 07:13 AM
Hi Anvesh, that is very helpful! Thank you!