Populate article number in kb_feedback_task table

bhavana2
Mega Contributor

Hi All,

There is a catalog item called "submit feedback" in which if user submits this form it will create an feedback task record in kb_feedback_task table.  Once it is submitted i have to map the article number field to the Article field in feedback task table.  But is not mapping correctly and coming empty. Apart from that i am able to map the author, desc and other fields.

I am using "current.article= producer.article_number;"   // inorder to map the "Article" field 

 since it is reference field i used  "current.feedback.article= producer.article_number;"

 But still it is not working. Can i know where i am doing wrong?

 Please let me know as it urgent requirement.  Early responses are highly appreciated

 

Thanks,

 Deepa

 

1 ACCEPTED SOLUTION

Ravi9
ServiceNow Employee
ServiceNow Employee

what is ur target table in rec prod ?

is it kb_feedback_task

then change the current.article = createdFeedbackFirst; TO

current.feedback = createdFeedbackFirst;

also ur code can be much simpler as well , something like below

var getNumber = producer.knowledge_article_number; // Article Number Variable here

current.feedback = createdFeedback(getNumber);

function createdFeedback(sys_id) {
  var gr = new GlideRecord("kb_feedback");
  gr.initialize();
  gr.article = sys_id;
  return gr.insert();
}

let me know

View solution in original post

15 REPLIES 15

shloke04
Kilo Patron

Also would like to mention here is that, if article number variable I have assumed is a reference type variable and based on this assumption I have shared the code above.

In case if it is not a reference variable and say it is a String Variable then you need to update your code as below:

var getNumber = producer.VariableName; //Replace "VariableName" with your Article Number Variable here
var getKB = getKBArticleID(getNumber);

var createdFeedbackFirst = updateKBFeedback(getKB);

if(createdFeedbackFirst){
current.article = createdFeedbackFirst; // This will update the Article field
}

function getKBArticleID(getNumber){
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('number',getNumber);
gr.query();
if(gr.next()){
return gr.sys_id;
}

}

function updateKBFeedback(getKB){
var gr = new GlideRecord('kb_feedback');
gr.initialize();
gr.article = getKB;
var succ = gr.insert();
if(succ){
return gr.sys_id;
}
}

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke