Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get the last cloned date/time of the "current" instance via server-side script?

doctorjim
Tera Contributor

I am needing to retrieve the date/time that the last clone was performed on the current (target) instance via server-side script.  Is there some hidden System Property I can fetch with gs.getProperty() or by using some other means?  The date/time only needs to be approximate (+/- 12 hours).  Querying the Clone History table would be very easy on my Production instance except that I need to do this on a non-Production instance.

9 REPLIES 9

I have even considered querying the stats.do page to retrieve the Started date shown below, but that's pretty convoluted, and I'm not sure that that date is guaranteed to be close to the actual clone date.



Servlet Statistics


Started: Mon Apr 17 22:13:58 PDT 2017


Mwatkins
ServiceNow Employee
ServiceNow Employee

You can get the servlet started value through the sys_status table. But you are right, it is not reliable because nodes may be restarted for many reasons.



var status = new GlideRecord("sys_status");


status.get("name", "system.startup");


var lastStartedDate = status.getValue("value");


Mwatkins
ServiceNow Employee
ServiceNow Employee

Hi Jim,


I don't have any concerns about the reliability of that record. It gets run after every clone and will be specific to the target instance. Looks like you found a good solution.


Matthew


Just a clarification that the URL I included above actually returns a list of Customer Updates created since the last clone was performed, and applies additional filter criteria that only returns updates that are within the scope shown in the current user's Application Picker.


billlefkoski
Tera Contributor

Since a clone almost always puts a strain on both the target and the source instance you  should be able to find a record in the slow Patterns Table accessed from System Diagnostics | Performance Windows | Latest Upgrade Label = "ASYNC: Schedule Instance Clone"

billlefkoski_0-1714075916645.png