
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2014 05:53 AM
This is question related to transactions which for some reason gets stuck and runs in the background utilizing system resources and slowing the instance down....
Whenever the instance is slow, i tend to check "All Active Transactions" menu and manually kill the transaction (ofcourse on the Developement instance)....
But I am just curious if anybody has some automated script or something that we can use to kill the long running transaction rather than manually going to the menu and killing it ....
Solved! Go to Solution.
- Labels:
-
Performance Analytics

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015 06:46 AM
Actually I created a UI page for this and have it on my home page on our development instance ... You have a script and a UI page in this ... Hope this helps ...
Script include:
var ScriptUtils= Class.create();
ScriptUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
killOldTransactions : function(){
try
{
var transactionCount = 0;
var getTransaction = new GlideRecord('v_transaction');
getTransaction.addEncodedQuery("age>javascript:gs.getDurationDate('0 0:10:0')");
getTransaction.query();
while(getTransaction.next()) {
transactionCount++;
GlideTransactionManager.kill(getTransaction.session_id.toString());
}
if(transactionCount == 0)
{
return 'No Transaction Were Cancelled';
}
else
{
return transactionCount + ' Transactions were cancelled';
}
}
catch(err)
{
return 'Error While Cancelling Transaction-'+err;
}
}
});
Ui page:
HTML:
<html>
<head>
</head>
<body>
<TABLE>
<TR>
<TD colspan='2' align="center"><input type="button" value="Cancel" onclick="cancelTransaction()"/> </TD>
</TR>
</TABLE>
</body>
</html>
Client Script of UI page:
function cancelTransaction(){
var cancelTrasaction = new GlideAjax("ScriptUtils");
cancelTrasaction.addParam('sysparm_name','killOldTransactions');
cancelTrasaction.getXMLWait();
alert(cancelTrasaction.getAnswer());
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015 06:46 AM
Actually I created a UI page for this and have it on my home page on our development instance ... You have a script and a UI page in this ... Hope this helps ...
Script include:
var ScriptUtils= Class.create();
ScriptUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
killOldTransactions : function(){
try
{
var transactionCount = 0;
var getTransaction = new GlideRecord('v_transaction');
getTransaction.addEncodedQuery("age>javascript:gs.getDurationDate('0 0:10:0')");
getTransaction.query();
while(getTransaction.next()) {
transactionCount++;
GlideTransactionManager.kill(getTransaction.session_id.toString());
}
if(transactionCount == 0)
{
return 'No Transaction Were Cancelled';
}
else
{
return transactionCount + ' Transactions were cancelled';
}
}
catch(err)
{
return 'Error While Cancelling Transaction-'+err;
}
}
});
Ui page:
HTML:
<html>
<head>
</head>
<body>
<TABLE>
<TR>
<TD colspan='2' align="center"><input type="button" value="Cancel" onclick="cancelTransaction()"/> </TD>
</TR>
</TABLE>
</body>
</html>
Client Script of UI page:
function cancelTransaction(){
var cancelTrasaction = new GlideAjax("ScriptUtils");
cancelTrasaction.addParam('sysparm_name','killOldTransactions');
cancelTrasaction.getXMLWait();
alert(cancelTrasaction.getAnswer());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2015 04:03 AM
Thanks, that's useful!