- 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-10-2022 11:44 PM
if the value in the reference field changes or any field in the record from the shipping details is changed you want to update the incident comments?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2022 12:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2022 07:43 AM
HI Bhavana, Any clue?
- 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