Business rule to take a choice list field value and populate a reference field

Jeff316
Kilo Guru

Hi All,

I'm using the oob business rule called "Incident Create Knowledge" to bring the "Category" from the Category string field (choice list) of the incident to the kb_category field on the Knowledge Article form which is a reference field.

So on the incident form Category field I have a choice value "hardware"

On the Knowledge Article form in the kb_category reference field I also have a value "hardware"

What is the syntax in the business rule to set category of incident with kb_category of knowledge article?

Ugh.

 

Thanks

 

1 ACCEPTED SOLUTION

hmm, i wonder if there is an issue with setDisplayValue because the field is translated. Not sure on that one, the below method will glide into the table and get the value to set instead:

Function submitDirect() {

var kb = new GlideRecord("kb_knowledge");
var category = current.getValue('category');

var gr = new GlideRecord('kb_category');
gr.addQuery('value', category);
gr.query();

if(gr.next()){
var catSysID = gr.getValue('sys_id');
 kb.kb_category = catSysID;
}

 kb.source = current.sys_id;
 kb.u_authoring_group = current.assignment_group;
 kb.author = current.resolved_by;
 kb.short_description = current.short_description;
 kb.text = current.close_notes;
 kb.description = current.description;	
 kb.insert();
}

View solution in original post

15 REPLIES 15

larstange
Mega Sage

Hi

It should be enough to do this

 

kb.category.setDisplayValue('value from incident');

 

assuming that there is a record in kb_category matching the category on the incident

Hi Lars,

Thanks for the help.

I'm pretty much using the oob business rule "Incident Create Knowledge"

But I'm pulling a few more fields from the INC to go into the Knowledge Article.

On the incident form is a string field with a choice list called 'category' and one choice is 'Application Software' with the value of application_software.

 

On the kb_knowledge form is a reference field called 'kb_category' which I have a record 'Application Software" with the value of "application_software"

Here is part of the business rule script where you can see me setting fields in the kb_knowledge form with values from the incident form.

I tried the syntax you suggested but no results.

 

 kb.u_authoring_group = current.assignment_group;
 kb.author = current.resolved_by;
  kb.short_description = current.short_description;
  kb.text = current.close_notes;
  kb.description = current.description;
 //kb.kb_category = current.category.getDisplayValue();
   kb.kb_category.setDisplayValue(category);
    kb.sys_domain = current.sys_domain;

 

 

 

I tried kb.kb_category = current.category.setDisplayValue();

 

but that didn't work either.

You'll need to get the display value of the choice field and set it as the display value of the reference field.

 

 

var category = current.getDisplayValue('category');
kb.kb_category.setDisplayValue(category);