Business Rule on History Table (sys_history_line)

augusto3
Kilo Contributor

Hello Guys,

I´m considering to create a Business Rule on History (sys_history_line) table, for when a specific record will inserted in this table I will create a record in another table.
But apparentely Business Rules doesn´t work for this table.

History LInes are created when I run this script for example

var gr = new GlideRecord("u_desktop");
gr.addQuery('name', 'AR00002713');
gr.query();
if ( gr.next() ){
  new GlideHistorySet("u_desktop", gr.sys_id).generate();
}


I think that is because we cannot use Business Rules in some system tables, am i right?

 

 

5 REPLIES 5

Harish Ragz
Kilo Guru

Hi,

Create a Business Rule as mentioned in below(It is an example only). It may help you.

When to Run:  After Insert

(function executeRule(current, previous /*null when async*/) {

var target = GlideRecord('target_table_name');
target.initialize();
target.record1=current.record1;
target.record2=current.record2;
target.record3=current.record3;
target.record4=current.record4;
target.insert();

})(current, previous);

Thanks,

Harish.

Jon Barnes
Kilo Sage
What’s the requirement? I can’t imagine creating a business rule on the history table would be what you would want anyway.

It´s for a report for control the date that their desktops were Installed.

I have to create a table like this bellow.

find_real_file.png

The problem is that I have to recovered this change of status that happenned in the past.

 

Ok so sys_audit contains the audit history of a record. But what record change needs to trigger setting this date?