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

Hi David,

That sounded good. Get the value then Set it.

I just tried that syntax but category won't come over from INC to KB

Maybe my var should NOT be the same name as the field.

 

Function submitDirect() {
    var kb = new GlideRecord("kb_knowledge");
 var category = current.getDisplayValue('category');
    kb.kb_category.setDisplayValue(category);
    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;

Add in a gs.log() to see what value the category variable is returning

 

gs.log('this is the category: ' + category);

The log returned this which is the category on the incident in the string field choice, but nothing was inserted into the kb_category field on the kb_knowledge form which has a reference field with that same label. The value for both fields is application_software

this is the category: Application Software

Is the kb_category field a reference field? If so, is there a field in the table it is referencing with the name Application Software?

 

Yes kb_category is a reference field on  the kb_knowledge form. The kb_category field references the kb_category table which has a record for the label of "Application Software" and the value of "application_software"

 

find_real_file.png