Incident - require a KB submission on closed

paw2
Tera Expert

I want to:     When checking the Knowledge checkbox on Incident Resolution section of incident form, a knowledge article is created from resolution/closure notes and sent to the "Knowledge" manager to approve for publication.

I believe this would use the (glide.knowman.submission.work), in this capacity:  

function submitCandidate() {

      var gr = new GlideRecord('kb_submission');

      gr.parent = current.sys_id;

gr.short_description = current.short_description;

      gr.sys_domain = current.sys_domain;

      gr.text = current.comments.getHTMLValue();

      gr.insert();

gs.addInfoMessage(gs.getMessage('Knowledge Submission created') + ':   ' + gr.number + ' ' + gs.getMessage('based on closure of Incident') + ': ' + current.number);

Where do I set this?   Is this a config dictionary off the KB label on the form?

1 ACCEPTED SOLUTION

Hi Patricia,



What i understood is you also want that if some one is resolving the incident (changing the state to "resolved"), you want to make knowledge to check true as a mandatory action.


If this is what you want then you can write a BR to automatically check the knowledge if state is resolved.


BusinessRule:


When-Before


Update-true


condition: current.state.changesTo(6)                 //assuming 6 is the value for resolved


Script:


current.knowledge = true;



If you want to write a client script then:


1.Client Script: (enforce user to check the knowledge check box)


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


if(g_form.isNewRecord()){


              return;


      }


      if (isLoading || newValue == '') {


              return;


      }


 


      //Knowledge article is mandatory if state is changed to resolved


g_form.setMandatory('knowledge', true);


g_form.showFieldMsg('state', 'Knowledge article is required when resolving incident.' , 'error', true);


}


2. Client Script(make the knowledge checkbox true automatically)


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


if(g_form.isNewRecord()){


              return;


      }


      if (isLoading || newValue == '') {


              return;


      }


 


      //Knowledge article is mandatory if state is changed to resolved


g_form.setValue('knowledge', true);




I would prefer to go with the Business rule.



PS: Hit answered, like, Helpful or Correct depending on the impact of the response


View solution in original post

3 REPLIES 3

anupama8
Tera Expert

Hi Patricia,



If You want to create a kb article on incident resolve/closure, you need to create a Business Rule on Incident (After-insert/update).



Condition: current.incident_state.changesTo(7) && current.knowledge == true



Script:


var sub = gs.getProperty('glide.knowman.submission.workflow');




if (sub == 'true')


      submitCandidate();


else


      submitDirect();




function submitDirect() {


      var kb = new GlideRecord("kb_knowledge");


      kb.source = current.sys_id;


      kb.short_description = current.short_description;


      kb.sys_domain = current.sys_domain;


      kb.text = current.comments.getHTMLValue();


      kb.workflow_state = 'draft';


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


      kb.insert();


      gs.addInfoMessage(gs.getMessage('Knowledge Article created') + ':   ' + kb.number + ' ' + gs.getMessage('based on closure of Incident') + ': ' + current.number);


}




function submitCandidate() {


      var gr = new GlideRecord('kb_submission');


      gr.parent = current.sys_id;


      gr.short_description = current.short_description;


      gr.sys_domain = current.sys_domain;


      gr.text = current.comments.getHTMLValue();


      gr.insert();


      gs.addInfoMessage(gs.getMessage('Knowledge Submission created') + ':   ' + gr.number + ' ' + gs.getMessage('based on closure of Incident') + ': ' + current.number);


}




PS: Hit answered, like, Helpful or Correct depending on the impact of the response


I also need to require a knowledge article to resolve an incident.   So onchange of the state to resolve, the Knowledge checkbox will need to be required and checked for true.   Would this be best accomplished with a UI, client script, or business rule?



Something like this?





Client script



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


if(g_form.isNewRecord()){


              return;


      }


      if (isLoading || newValue == '') {


              return;


      }


   


      //Knowledge article is mandatory if state is changed to resolved


//g_form.setMandatory('state', resolve);


g_form.showFieldMsg('state', 'Knowledge article is required when resolving incident.' , 'error', true);


}


Hi Patricia,



What i understood is you also want that if some one is resolving the incident (changing the state to "resolved"), you want to make knowledge to check true as a mandatory action.


If this is what you want then you can write a BR to automatically check the knowledge if state is resolved.


BusinessRule:


When-Before


Update-true


condition: current.state.changesTo(6)                 //assuming 6 is the value for resolved


Script:


current.knowledge = true;



If you want to write a client script then:


1.Client Script: (enforce user to check the knowledge check box)


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


if(g_form.isNewRecord()){


              return;


      }


      if (isLoading || newValue == '') {


              return;


      }


 


      //Knowledge article is mandatory if state is changed to resolved


g_form.setMandatory('knowledge', true);


g_form.showFieldMsg('state', 'Knowledge article is required when resolving incident.' , 'error', true);


}


2. Client Script(make the knowledge checkbox true automatically)


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


if(g_form.isNewRecord()){


              return;


      }


      if (isLoading || newValue == '') {


              return;


      }


 


      //Knowledge article is mandatory if state is changed to resolved


g_form.setValue('knowledge', true);




I would prefer to go with the Business rule.



PS: Hit answered, like, Helpful or Correct depending on the impact of the response