- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 05:48 PM - edited ‎10-11-2022 08:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2022 01:24 AM - edited ‎10-11-2022 01:25 AM
Hi @devservicenow k ,
Fields:
u_viewedrecord -reference field type on Case/Incident table,
u_username - User reference field type on User table,
u_usertime - Date/Time filed type
No need 2 reference fields on case table. u_parent, u_viewedrecord. Use any one of them.
Create display business rule on case table. but I tried on Incident table.
Script:
(function executeRule(current, previous /*null when async*/ ) {
var graud = new GlideRecord("u_audit"); //audit table name
graud.initialize();
//graud.u_viewedrecord = current.sys_id; // current.sys_id and getunique value both will work as same.
graud.u_viewedrecord = current.getUniqueValue();
graud.u_username = gs.getUserID(); // to get the user id
graud.u_usertime = new GlideDateTime(); // to get the time that viewed by user
graud.insert();
})(current, previous);
Give all your field names that you created on audit table it will work.
Relationship Query:
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
current.addQuery('u_viewedrecord', parent.sys_id);
})(current, parent);
Audit records LIST:
Audit Relationship: It will display only parent incident/case related records.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2022 07:50 PM - edited ‎10-11-2022 08:33 AM
someconfiguration issue in fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2022 11:20 PM
Hi @devservicenow k,
Have you tried by clicking the search icon in u_viewedrecord field/column? which list it shows?
Thanks,
Sagar Pagar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2022 11:45 PM
I believe I have answer your question in another thread.
It was an issue of display field of Case table. Records are created with correct values but it shows empty display values on Parent and AuditedRecord field.
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2022 01:24 AM - edited ‎10-11-2022 01:25 AM
Hi @devservicenow k ,
Fields:
u_viewedrecord -reference field type on Case/Incident table,
u_username - User reference field type on User table,
u_usertime - Date/Time filed type
No need 2 reference fields on case table. u_parent, u_viewedrecord. Use any one of them.
Create display business rule on case table. but I tried on Incident table.
Script:
(function executeRule(current, previous /*null when async*/ ) {
var graud = new GlideRecord("u_audit"); //audit table name
graud.initialize();
//graud.u_viewedrecord = current.sys_id; // current.sys_id and getunique value both will work as same.
graud.u_viewedrecord = current.getUniqueValue();
graud.u_username = gs.getUserID(); // to get the user id
graud.u_usertime = new GlideDateTime(); // to get the time that viewed by user
graud.insert();
})(current, previous);
Give all your field names that you created on audit table it will work.
Relationship Query:
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
current.addQuery('u_viewedrecord', parent.sys_id);
})(current, parent);
Audit records LIST:
Audit Relationship: It will display only parent incident/case related records.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar