<h2>Loading the audit history list or calendar of a particular record takes a very long time to load where it times out my transaction</h2><br/><div style="overflow-x:auto"><article><div ><h3 >Issue </h3><section><h4> </h4> <h4><strong>- When I get on a form, then click the 'List Controls' (on the upper left) ---> then click History -----> Calendar OR List, it takes a very long time to load where it also times out.</strong></h4> <h4> </h4> <h4><strong>- This only happens on certain records and not all records</strong></h4></section></div><div ><h3 >Cause</h3><section><h4> </h4> <h4><strong>1) This is related to PRB645035 where there is no permanent fix because it is expected behavior for the history set to take a very long time when there is a lot of audit history for a particular record </strong><br /><br /></h4> <h4><strong>2) Every time you click the history List, it executes the below UI action to create the history set, <span style="color: #ff0000;"><strong>if there is no existing history set, or if the history set is expired after a month, or if there were updates made to the particular record:</strong></span><br /><br /></strong></h4> <pre>UI Action - Show History <br />https://<span style="color: #ff0000;"><strong>[Instance-Name]</strong></span>.service-now.com/sys_ui_action.do?sys_id=7eda37860a0001c700824a6f277327b0 <br /> <br /> Object Type: UI Action [sys_ui_action] <br /> Sys ID: 7eda37860a0001c700824a6f277327b0 <br /> Field Name: script <br /> Line Number: 2 <br />Function Name: script <br /> <br /> 1: var hs = new GlideHistorySet(current); <br /> 2: >>> var sys_id = hs.generate(); <br /> 3: <br /> 4: action.setRedirectURL("sys_history_set.do?sys_id=" + sys_id); <br /> 5: action.setReturnURL(current);<br /> </pre></section></div><div ><h3 >Resolution</h3><section><h4> </h4> <h4><strong>There are a couple of solutions that can be done:</strong></h4> <h4> </h4> <h4><span style="text-decoration: underline;"><span style="color: #ff0000;"><strong>Solution One (Recommended):</strong></span></span></h4> <pre><strong>Delete old audit data and minimize the audit record list to lower than 1,000 for the particular record that takes a long time to load the sys_history_set</strong></pre> <h4> </h4> <h4><span style="text-decoration: underline;"><span style="color: #ff0000;"><strong>Solution Two:</strong></span></span></h4> <h4><strong>a) Go to https://<span style="color: #ff0000;">[Instance-Name]</span>.service-now.com/sys.scripts.do</strong></h4> <h4><strong> </strong></h4> <h4><strong>b) Run the below script to manually build the history set for the particular record that has too many audit records:</strong></h4> <h4> </h4> <h4><span style="color: #ff0000;"><strong>NOTES:<br /></strong></span></h4> <pre><span style="color: #ff0000;"><strong>i.) Make sure the below sys_id is the sys_id of the record your getting the history set on<br /></strong></span><br /><strong>ii.) Since the script below will take a long time, open a new browser in incognito mode/ private mode and re-login to Servicenow to do other stuff as your long script is running so your not impacted by session_wait_time</strong><br /><br /><strong>What is session_wait_time?</strong><br /><strong><span style="color: #ff0000;">This occurs when a user executes too many transactions at a time in parallel. A user can only access one transactions at a time as designed. This issue occurs a lot when a user has too many Servicenow tabs open and works too fast. For Example: If you access or save anything on a form, then while thats running you immediately try to access or save another form, your second transaction will still be waiting for the first transaction to finish before it can finish your second transaction. You can get around this if you open a brand new browser in incognito mode/private mode where it will allow a user to run 2 transactions in parallel instead of just one.</span></strong></pre> <h4> </h4> <h4><strong>Script:</strong></h4> <pre><strong>//------------------------------Start Code---------------------------------------<br /><br /></strong><strong><span style="color: #ff0000;">// -- GlideHistorySet will accept either a GlideRecord object or (table,sys_id) as parameters.</span></strong><br /><strong><span style="color: #ff0000;">// -- For dynamically fetched records, you can use the below or GlideRecord Query to fetch multiple and iterate</span><br /><span style="color: #ff0000;"><br />//var gr = new GlideRecord('incident');</span><br /><span style="color: #ff0000;">//gr.get('number','INC000123');</span><br /><span style="color: #ff0000;">//var hs = new GlideHistorySet(gr);<br />//var sys_id = hs.generate();</span><br /><br />var hs = new GlideHistorySet('incident','82cd9e8d2bb669c083845b5fe8da15c2') <span style="color: #ff0000;">//<----------- For a single targeted record<br /></span></strong><strong>var sys_id = hs.generate();</strong><br /><br /><strong>//----------------------------END CODE-----------------------------------------</strong></pre> <h4> </h4> <h4><span style="text-decoration: underline;"><span style="color: #ff0000;"><strong>Solution Three:</strong></span></span></h4> <pre><strong>Use the same code above on two areas:</strong><br /><br /><strong>a) On a scheduled job, so it executes once a month</strong><br /><br /><strong>b) On a 'async' business rule to execute every time there is an update on the record that has too many audit records</strong></pre></section></div></article></div>