Knowledge Management - Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 07:57 PM
Hi,
I have a requirement wherein I need to make "Details" mandatory on the feedback popup but only for articles with some specific knowledge bases like ABC, DEF.
I have found ways to make it mandatory, however it gets mandatory for all Knowledge bases. I only want for some specific ones.
How can this be achieved?
Your help is appreciated.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 08:54 PM
Please share your current approach to making it mandatory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 10:51 PM
I have cloned the widget Knowledge Article Content and added below highlighted code to the Client Controller function c.submitFeedbackTask
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 11:00 PM - edited 03-13-2024 11:05 PM
In the server code of the widget you can determine if the current articles knowledge base is one that the details should be mandatory for, and if so, set a property on data to true. Then in the client script you can check this property (see code comments for details):
// Insert into around line 77 of server code
var kbArticle = kbViewModel.knowledgeRecord; // get the article
if(kbArticle) {
// get the sys_id of the associated knowledge base
var articleKB = kbArticle.getValue("kb_knowledge_base");
// a comma separated list of knowledge base sys_ids (stored in a system property for example)
var mandatoryDetailKBs = gs.getProperty("YOUR_SYSTEM_PROPERTY", "");
// true if the current article's KB is in the list in the system property
data.detailsMandatory = mandatoryDetailKBs.indexOf(articleKB) > -1;
}
Then you can update your client script to use data.mandatoryDetails to determine if you should check if the field has been populated:
c.submitFeedbackTask = function(){
var detailsIncomplete = c.data.detailsMandatory && !c.data.details.trim();
if(!c.data.reason || detailsIncomplete){
c.flagMessage = "${Please provide the mandatory details}";
$("#detailsComment").focus();
return false;
}
else{
c.submitted = true;
c.closePopup();
}
}