- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 09-19-2020 12:14 AM
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
- 960 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Yash
Thank you for sharing it ,I would recommend using Insert/edit sample option for any kind of scripts in your article.
Link to article
https://community.servicenow.com/community?id=community_article&sys_id=683e067edbae1c50fb115583ca9619c1
Thanks
Pranav
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello Pranav,
Thankyou for your suggestion,I will surely do that.
But just a question,do you know that after getting comment on my article,if now I modified it,your helpful marked will get lost or not.
Regards,
Yash Agrawal
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Yash
Don't worry ,nothing will be lost 🙂
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello Pranav,
Is it looking Good now.
Regards
Yash Agrawal
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
yups 🙂