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

Knowledge Management - Service Portal

savvyjain
Tera Contributor

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

savvyjain_0-1710298373349.png

 

3 REPLIES 3

Nick Parsons
Mega Sage

Please share your current approach to making it mandatory.

I have cloned the widget Knowledge Article Content and added below highlighted code to the Client Controller function c.submitFeedbackTask

savvyjain_0-1710309044389.png

 

 

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();
  }
}