String conversion to HTML-Incident to knowledge creation

Rajiv Kumar Jh1
Giga Contributor

Hello Experts,

We have BR to auto-create KB from incident. In description fields we put issue detail in multi line text. When KB created from incident then KB show all multi line text in single line. There is some issue in conversion of string field to HTML.

Adding BR, Incident and KB here.

var k = new GlideRecord('kb_knowledge');
k.topic = "temp Fix" ;
k.u_category = current.category;
k.u_sub_category = current.subcategory;
k.u_subject = current.short_description;
k.u_symptom_text = current.description;
k.u_cause_text = current.u_cause_text;
k.u_work_around_text = current.close_notes;
k.sys_created_on = current.assigned_to;
k.workflow_state = "draft";
k.short_description = current.short_description;
k.u_company = current.company;
k.u_partner_name = current.assigned_to.company.name;
k.source = current.sys_id;
k.u_incident=current.sys_id;
k.kb_knowledge_base = gs.getProperty("glide.knowman.task_kb", "bc6d656adb153200b75f719dae96192d");

//var grp = new GBPKnowledgeUtil().getGroupManual(current.company, 'L5') ;
//know.u_assignment_group = grp;
//know.insert();
k.insert();

Appreciate your prompt response here.

Regards,

RK

1 ACCEPTED SOLUTION

Hello Chuck,

 

Thanks for your response. There was no concern with fields as mentioned by creativethinker. I have added these line and commented kb.text only. its working fine.

 

var k= current.getValue('description');
 var html1=k.replace(/\n/g,'<br/>');
 kb.text=html1;
    //kb.text = current.description.getHTMLValue();

Thanks for your input. Happy Friday:)

View solution in original post

5 REPLIES 5

Ct111
Giga Sage

Hi Itsmraj2015,

 

There is no field called 

 

k.u_category = current.category;

 

change it to

 

k.kb_category =  current.category;

 

and there is no Sub category in knowledge table. 

I would request you to crosscheck the names of all the fields by going to kb_knowledge table only then alter the script .

 

PLEASE mark my ANSWER as CORRECT if it served your purpose.

Hello Creativethinker,

Thanks for your response. There was no concern with fields as mentioned by you. I have added these line and commented kb.text only. its working fine.

 

var k= current.getValue('description');
 var html1=k.replace(/\n/g,'<br/>');
 kb.text=html1;
    //kb.text = current.description.getHTMLValue();

Thanks for your input. Happy Friday:)

Chuck Tomasi
Tera Patron

After you have checked the field names as indicated in the previous reply, you can use something like this to insert <br /> tags in your text field. Note, this code has not been updated:

 

var text = current.getValue('description');
var html = text.replace("\n", "<br />");
kb.u_symptom_text = html;

 

Hello Chuck,

 

Thanks for your response. There was no concern with fields as mentioned by creativethinker. I have added these line and commented kb.text only. its working fine.

 

var k= current.getValue('description');
 var html1=k.replace(/\n/g,'<br/>');
 kb.text=html1;
    //kb.text = current.description.getHTMLValue();

Thanks for your input. Happy Friday:)