How can we show fields changes to Activity streams

ST9
Tera Contributor

I want to show the field value changes from another table in activity stream.

Eg- In incident table i have referenced field( table= shipping details ) and any changes/update made in field from shipping details table should be captured in additional comments in Incident form.

1 ACCEPTED SOLUTION

Hi,

I tried the below sample of code to Update the incident worknotes whenever the caller (referencing the sys_user table is updated)

Note: In my case i have taken the reference table as "sys_user"

find_real_file.png

code as below:

var gr = new GlideRecord('sys_dictionary');
gr.addQuery('name=sys_user^ORname=task^element!=NULL'); // Replace 'incident' by the table that is relevant to you
gr.query();
while (gr.next()) {
if (current[gr.element] != previous[gr.element])
if (gr['element'] != 'sys_mod_count' && gr['element'] != 'sys_updated_by' && gr['element'] != 'sys_updated_on') {  // refer screenshot below(pic -2) to understand why this condition is added
gs.addInfoMessage('Field ' + gr['name'] + '.' + gr.element + ' has changed!'); // Insert your here code to save log where you want
var a = 'Field ' + gr['name'] + '.' + gr.element + ' has changed!';
var gr = new GlideRecord('incident');
gr.addQuery('caller_id', current.sys_id);
gr.query();
//gs.log("row counts::" + gr.getRowCount());  --- verify the row count before updating the record
while (gr.next()) {
gr.work_notes = a;
gr.update();
}
}

pic -2 :- when we update the record It takes "Updated", "Updated By" into consideration and hence in the above if condition we are excluding it....

find_real_file.png

Please change the table in your case to "shipping details" and replace the corresponding fields

View solution in original post

7 REPLIES 7

Hi Bhavana, 

Thank you very much, it worked well !!

Can you please help me to understand why we have gliderecord to sys_dictionary table ?

 

If you want to track the Updates happening in the record then you should GlideRecord the Dictionary table,

I am not sure about the other alternative approach and try if you get any alternative solution, also let us know if you need any help further.

Sure, Thanks for your help.