How to search Initial Value of fields after record modified multiple times
Import
·
Sep 19, 2020
·
article
Hello ServiceNow Users,
Let's say you want the Initial values of all the fields in the record of a particular table. Many time hear from many users, that it is not possible.
But actually, it is possible.ServiceNow provides you a facility to check the initial values of any record even after that record values updated multiple times.
You Can follow the below code to get the Initial Values of any record in any table.
Here I am fetching all the incidents whose CI's initial value is blank when initially the incident was created.
var arr=[];
var grincident=new GlideRecord('incident');
grincident.query();
while(grincident.next())
{
var grhistory=new GlideRecord('sys_history_set');
grhistory.addQuery('id',grincident.sys_id);
grhistory.query();
if(grhistory.next())
{
var name = gs.getXMLText(grhistory.initial_values,"//cmdb_ci");
if(name==null)
{
gs.addInfroMessege('Incident has No CI initially-'+grincident.number);
}
else
{
gs.addInfroMessege('Incident has CI initially-'+grincident.number);
}
}
}
Regards,
Yash Agrawal
View original source
https://www.servicenow.com/community/developer-articles/how-to-search-initial-value-of-fields-after-record-modified/ta-p/2321127