UI Action to update incident with a related list record number

oharel
Kilo Sage

Hi all,

My incident form has a related list called kb, where knowledge articles are shown. The articles are filtered according to the category and area of the incident.

I am looking for a UI Action to update my incident's work_notes upon choosing a record from related list on the incident form.

I am not able to get the sys_id of the kb record I chose in order to insert it into the incident's work_notes.

When the UI action on the incident form is on the related list table (RP.isRelatedList()), I can either get the id of the incident form (client side) or the id of the kb using server side script. But not both.

Any help would be appreciated.

Harel

1 ACCEPTED SOLUTION

Got you.You need to write a client side code in the UI action and call script include and return all the values you need from the checked article and save it on to the form. Here is a sample script that will get you the information from related problem record and updates the description on to the parent incident record.



UI Action Code:


function getNumber(){


  var id=g_list.getChecked();


  var ga = new GlideAjax('GetDetails');


  ga.addParam('sysparm_name','getNumber');


  ga.addParam('sysparm_ids',id);


  ga.getXML(callBack);


  function callBack(response){


  var answer = response.responseXML.documentElement.getAttribute("answer");


  g_form.setValue('description',answer);


  g_form.save();


  }


}



Script Include:


var GetDetails = Class.create();


GetDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {


getNumber: function(){


  var gr= new GlideRecord('problem');


  gr.get(this.getParameter('sysparm_ids'));


  return gr.number;


},


      type: 'GetDetails'


});


View solution in original post

12 REPLIES 12

oharel
Kilo Sage

Anyone has an idea on how to tackle this?


Harel


Abhinay Erra
Giga Sage

Is the UI action on the knowledge articles related list or incident form?


Hi Abhinay,



There are three tables involved:


1. incident


2. knowledge


3. u_incident_kb - this table has three relevant fields, taken from the other two tables: category and area from the incident form and article number from the knowledge table. The way I did it is like this:


You can add to a knowledge article, using a related list, relevant category and area to the article. A record is created in the u_incident_kb table.


Once you do that, if an incident opens with the relevant category and area, a related list on the incident form (querying from u_incident_kb) shows you a list of the relevant articles.


What I would like to do is be able to put a check mark on one of the knowledge articles and click on a UI Action. The UI action will then add a work_note to the incident form (the one that I am working on) that says something like: article <article number> helped solve the issue.



I could not get the same UI Action to retrieve the knowledge article number from the u_incident_kb table and update the incident form I was on.


I thought it had to do with client-server scripting in the same UI, by the way. I am not sure as i could not get it to work



Thanks for any idea,


Harel


Geoffrey2
ServiceNow Employee
ServiceNow Employee

I have a feeling your answer is going to involve some GlideList2 function: GlideList2 (g list) - ServiceNow Wiki


Can you provide a screenshot of where you want the UI Action to appear?