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

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

Got it-- so the field in your screenshot does not belong to the current kb_feedback_task record, it is dot-walked to the referenced Feedback reference field record's reference field for article.

So with that in mind your variable that is currently referencing kb_knowledge table should actually be referencing the kb_feedback table and displaying the article field in the front-end variable dropdown via ref_ac_columns variable attribute.

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

 Yes Christopher.

 But can i know how to fetch that?

shloke04
Kilo Patron

Hi @bhavna 

This might be happening because Article field on KB Feedback task table does not refer directly to Kb_knowledge Table.

By default that field refers to another table named as "kb_feedback" and it is this table which refers to kb_knowledge table.

So, to achieve your requirement, you need to follow the steps below:

Update your record producer script as below:

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

var createdFeedbackFirst = updateKBFeedback(getNumber);

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

function updateKBFeedback(getNumber){
var gr = new GlideRecord('kb_feedback');
gr.initialize();
gr.article = getNumber;
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

@bhavna 

Let me know if you have a follow up query, else please mark the answer as correct and close this thread for others.

Regards,

Shloke

Hi Shloke,

I have kept the same code and changed the backend value of mine but still it's not working