data policy on knowledge base

anasuyaray
Kilo Expert

HI,

There is a data policy on knowledge called Enforce Knowledge Base Field. It is setting knowledge base mandatory while inserting the record.

Problem Create Knowledge business rule is inserting the knowledge from a closed problem and it is setting the value of knowledge base:

kb.kb_knowledge_base = gs.getProperty("glide.knowman.task_kb", "dfc19531bf2021003f07e2c1ac0739ab");

I want knowledge base field to be empty and mandatory while creating the knowledge article from problem. Otherwise it should be working as it is.

How to give this condition ? I have tried to write an insert business rule, But it is throwing data policy exception from Enforce Knowledge Base Field

(function executeRule(current, previous /*null when async*/) {

var ob = new GlideRecord('problem');

  ob.addQuery('sys_id',current.source);

  ob.query();

  if(ob.next()){

  current.kb_knowledge_base ='';

  }

})(current, previous);

Please help me out in this.

Regards,
Anasuya

6 REPLIES 6

Abhinandan Pati
Giga Guru

Hi Anasuya,



What do you mean by below sentence?



I want knowledge base field to be empty and mandatory while creating the knowledge article from problem.



I think you can resolve this issue by making changes in data policy itself.



Thanks,


Abhinandan


When a knowledge is created from problem, by default "knowledge" knowledge base is added as the knowledge base of the article.


I want it to be empty, while created from problem.



I can not see any advanced check box in data policy where I can write the code to restrict


If this data policy is active you won't be able to create knowledge without having this field filled...


So you can provide some default/desired value in the below line to make it work..Just a suggestion...



kb.kb_knowledge_base ="Some Value".



Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.



Thanks,
Deepa


Hi Anasuya,



This is happening due to business rule configure which creates a knowledge article.


You will have to play around with that business rule to modify the behaviour.



Here goes the link for BR


https://<InstanceName>.service-now.com/sys_script.do?sys_id=877c97b80a0a3c740147ca0a46126576