- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2022 11:18 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2022 10:59 AM
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"
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....
Please change the table in your case to "shipping details" and replace the corresponding fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2022 11:54 PM
Hi Bhavana,
Thank you very much, it worked well !!
Can you please help me to understand why we have gliderecord to sys_dictionary table ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2022 11:58 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 01:09 AM
Sure, Thanks for your help.