need fix script to copy the html field in kb_knowledge base to another Html field of article templat

mastanbe
Tera Contributor

Hi Everyone,

 

I have a requirement that i need to copy the content from one Html field (question field) to another HTML field(Answer field).

Here Question field was created in Knowledge base table (kb_knowledge_base).

and i created one custom HTML field Called it as Answer field in Article template table (kb_template_faq).

now i have to copy the data from Question field to Answer field , but iam unable to copy the data.

Could You please help me on this one.

 

 

2 REPLIES 2

Matthew Knight
Tera Guru
function copyHTMLField(copyFrom, copyTo){
    var ka = new GlideRecord('kb_knowledge');
    ka.get(copyFrom);

    var kTemplate = new GlideRecord('kb_template_faq');
    kTemplate.get(copyTo);


    kTemplate.<html field name here> = ka.text;
    kTemplate.update();


}

copyHTMLField('<enter sys id of question record>', '<enter sys id of answer record');

Why not try something like this.  You can then pass the values into the function from a gliderecord in a loop if you wanted to complete this for many records at once

This does not copy over exactly the HTML code, for example those nasty "&nbsp;" strings are ignored, not copied over. So the two HTML fields will not be exactly the same.