Should Record Watch work on any table?

Brian Treichel
Tera Guru

I'm trying to setup some favorites functionality for a portal using the sp_log table to store the 'favorites' (rather than creating a custom table). This table works well for me because it has all of the attributes I would need anyways (the user, the 'document' i.e. catalog item,etc.).

Everything is working fine when favoriting items (the records are getting created/updated appropriately), but I figured I would add a header menu item so that users can access Favorites quickly. I've tried both filtered and scripted list type menu items, but can't get the record watch to work on the 'sp_log' table. I was actually originally using the 'sys_user_preference' table, which didn't work either (may be unrelated though). 

In the console, it looks like it registers the record watcher fine, and the filter returns results when queried manually. 

     init sp_log?type=Cat Item Favorite^userDYNAMIC90d1921e5f510100a9ad2572f2b477fe^count=1^EQ

But updates are not being logged as I would usually see. 

    i.e. something like: record update: sc_req_item.a442b81adb514450516cf2b6ae9619ed RITM0010053

 

My question: Are there types of records that record watch doesn't work for?

 

Here is the scripted list code: 

var t = data;  // shortcut
t.items = [];

var u = gs.getUser().getID();
var query = 'type=Cat Item Favorite^user=' + u;

$sp.log("running favorites menu script"); // test to see if it's re-running after record updates

t.record_watchers = [];
t.record_watchers.push({'table':'sp_log','filter':query});

var z = new GlideRecord('sp_log');
z.addEncodedQuery(query+"^count=1"); //'active' favorites
z.orderByDesc('sys_updated_on');
z.query();

while (z.next()) {
  var a = {};
  var item_id = z.getValue('id');
  a.title = z.getDisplayValue('text');
  a.sys_id = item_id;
  a.__table = "sp_log";
  a.type= "link";
  a.href= "?id=sc_cat_item&sys_id=" + item_id;
  t.items.push(a);
}

t.count = t.items.length;
3 REPLIES 3

Brian Treichel
Tera Guru

For anyone else that has this issue, here is the answer:

Record watcher is by default enabled for most of the tables in ServiceNow, However it might not work on a few black listed tables

glide.record_watcher.table.blacklist - System Property governs the list of tables that are avoided for record watcher.

System Default black listed tables: sp_log,sys_status,pa_job_logs,sys_trigger,sys_rw_amb_action,sys_rw_action,ua_app_usage,usageanalytics_count_cfg,ua_app_metadata,usageanalytics_count,license_details,role_has_license,wf_workflow_execution,wf_history,sys_email,clone_token,wf_executing,clone_token,wf_executing,sys_email_account,sys_user_session,wf_command,sys_user_token,clone_preserved_data,wf_context,sys_update_version,wf_transition_history,instance,digest_properties,sso_properties,saml2_update1_properties,sso_federation,sys_cache_flush,sys_broadcast_message,sys_broadcast_message_m2m,sys_audit_relation,sys_audit_delete,sys_cluster_message,sys_cluster_state,sys_db_cache,sys_dictionary_override,sys_email_log,sys_event_processor,sys_glide_object,sys_import_set,sys_import_set_row,sys_import_set_row_error,sys_import_set_run,sys_update_set,sys_update_set_log,sys_update_set,sys_update_xml,sys_upgrade_history,sys_upgrade_history_log,sys_user_preference,sys_user_session,sys_progress_worker,sys_progress_worker_domain,sys_report_summary,sys_report_summary_line,sys_ui_navigator_history

To allow access to a blacklisted table, Create the system property excepting the table from the above list.

Please Note: Enabling record watcher for a blacklisted table might cause performance issues.

To blacklist some extra tables in addition to the default tables, create a system property "glide.record_watcher.table.blacklist.additional" and put the table names:

e.g. incident, change_request.

Thank you for the info! What property would except a table from the blacklist? And I don't see that table.blacklist property in our instance...is that something you created? Thanks!

Joe72
Tera Contributor

All the evidence I'm seeing point to the existence of this property, but it is also hidden for me. This is the only documented page that includes 'glide.record_watcher.table.blacklist.additional':

https://hi.service-now.com/kb_view.do?sysparm_article=KB0726337

I'm digging around to find the exception property, but so far, no luck.

Working: Create the system property, 'glide.record_watcher.table.blacklist', and just remove the tables that you need to watch!