maximum execution time exceeds error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2023 05:38 AM - edited ‎09-26-2023 05:38 AM
Hello experts,
I have written below script to delete multiple records. The script is functioning fine, successfully deleting approximately 7,000 out of 20,000 records. but I want to delete all 20000 records .when I try to delete records after 5 -10 min it shows mean information message indicating that data retrieval from the server failed due to a transaction cancellation.
Cancellation reason: Maximum execution time exceeded.
How can I rectify this error and ensure that all 2
UI Action:
function cleanup() {
var c = confirm("Are you sure you want to perform cleanup?");
if (c) {
var ga = new GlideAjax('MyGlideAjaxScriptInclude'); // Replace with the name of your Script Include
ga.addParam('sysparm_name', 'CleanUPEvents');
// ga.addParam("sysparm_sys_id", "abc");
ga.getXML(updateCampus); //sync call
function updateCampus(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer) {
alert("cleanup successfull");
setTimeout(function() {
location.reload(true);
}, 500);
} else {
alert("No record Found");
}
}
// Check if the response indicates success or failure
} else {
// User cancelled the operation
alert("Cleanup operation canceled.");
}
}
------------------------------------------------------------------------------------------------------------
Script Include:
var MyGlideAjaxScriptInclude = Class.create();
MyGlideAjaxScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
CleanUPEvents: function() {
gs.log("Script Called by UI action");
try {
gs.log("Script Called by UI action try blcok");
var gr = new GlideRecord('u_ma_frm_event');
gr.addQuery('u_ma_fld_state', 'closed');
gr.addNotNullQuery('u_ma_fld_number');
gr.query();
gr.setWorkflow(false);
gs.log("delete multiple count"+gr.getRowCount());
if(gr.getRowCount()>0)
{
gs.cacheFlush();
gr.deleteMultiple();
return true;
}
gs.log("Script Called by UI action try blcok 11"+gr.getRowCount());
} catch (ex) {
gs.error("An error occurred in CleanUPEvents: " + ex);
return false;
}
},
type: 'MyGlideAjaxScriptInclude'
});
0,000 records are deleted? Kindly provide guidance. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2023 05:50 AM - edited ‎09-26-2023 05:57 AM
Hi @Mark Wood
It is the expected behavior and it is not recommended to delete those many records through GlideAjax. Try using some scheduled script.
You can check transaction quota rules for your execution time limits.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2023 08:06 AM
Hello @AnveshKumar M ,
I have created quota rules and defined the seconds, but it's still not working. I have attached a screenshot below. If I am making any mistakes while creating the quota rule, please correct me. Thanks for your assistance.