bernyalvarado
Mega Sage

Hi Julian,



Based on the data you shared it appears that you're not getting null for REQ0015744 on none of the background scripts. In fact, they appear to have the same time.



Would you mind rephrasing your question so that we can have a better understanding of the problem you're facing?



Thanks,


Berny


poyntzj
Kilo Sage

Hi Berny


If I run a query that will take the sys_id of the REQ record, look at the sys_history_set.   I get the relevant information i need and then try to query the sys_history_line table to return the latest close_code entry


I need to populate a field on the REQ table


When I run the query I often find lots of null entries


If I go into the record, at the bottom we see the Activity states - including the one I am searching for


If I now got back and run my query again, I now get to see the data from the sys_history_line.



It is as if I need to force the line to load to do this.



I did try against the sys_audit table and got a similar problem


Hi Julian, I now understand what you're looking for. Indeed it's odd how records get added to the audit / history tables. The good news is that there is a work around.



On your case you can create an Insert / Update OnAfter business rule in the change_request table and have a script like the following:



new GlideHistorySet("change_request", current.sys_id).generate();



That will make the trick



Thanks,


Berny


View solution in original post

This function is amazing, thanks for sharing the info!

poyntzj
Kilo Sage

I shall have a look at this a little later this week



Cheers