knowledge article pre populate values

RadZz
Tera Contributor

Hello team,

 

I have requirement to pre-populate a field and I was able to do it but client recently added few conditions and not sure what went wrong here.

Conditions : When a new record/ article is created and knowledge base is : Employee knowledge and for any article template ( standard is default and we have couple more templates ) it should pre -populate can read field. So my code is : 

 

I gave condition as new record then checking kb_knowledge_base value  if the value is 'employee knowledge' (sys id mentioned ) then new gliderecord to get all the templates and mentioned condition active true here  and set the value for can read.  Any changes recommended for this? 

 

 

function onLoad() {
 if (g_form.isNewRecord()) {
   var checkKnowledgeBase = function() {
     var knowledgeBaseValue = g_form.getValue('kb_knowledge_base');
     if (knowledgeBaseValue) {
       if (knowledgeBaseValue === 'bb0370019f22120047a2d126c42e7073') {
         var articleTemplateGr = new GlideRecord('kb_article_template');
         articleTemplateGr.addQuery('active', true);
         articleTemplateGr.query();
         if (articleTemplateGr.next()) {
           g_form.setValue('can_read_user_criteria', '40a5329cdb08d6109a92c6cd139619b8');
         }
       }
     } else {
     
       setTimeout(checkKnowledgeBase, 30);
     }
   };
   checkKnowledgeBase();
 }
}
 
TIA 🙂
 
0 REPLIES 0