Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

SLARepair- Global

The SLARepair script include provides methods that delete the existing SLAs and then recreates them from each task's history.

Parent Topic:Server API reference

SLARepair - repairByFilter(String filter, String sourceTable)

Repair the task SLAs associated with the passed-in filter and source table.

NameTypeDescription
filterStringEncoded query that is used to retrieve a set of records from the source table.
sourceTableStringName of a table that is (or extends) contract_sla, task_sla, or task.
TypeDescription
void 

Repair SLAs for problems created last month with a priority of 2.

var now_GR = new GlideRecord("problem");
now_GR.addQuery("sys_created_on", "ON", "Last Month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()");
now_GR.addQuery("priority", "2");
now_GR.query();

var repair = new SLARepair();
repair.repairByFilter(now_GR.getEncodedQuery(), now_GR.getRecordClassName());

SLARepair - repairByGlideRecord(GlideRecord now_GR)

Repair the task SLAs associated with the passed in GlideRecord.

NameTypeDescription
now_GRGlideRecordGlideRecord for a table that is (or extends) contract_sla, task_sla, or task.
TypeDescription
void 

Repair SLAs for problems created last month with a priority of 2.

var now_GR = new GlideRecord("problem");
now_GR.addQuery("sys_created_on", "ON", "Last Month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()");
now_GR.addQuery("priority", "2");
now_GR.query();

var repair = new SLARepair();
repair.repairByGlideRecord(now_GR);

SLARepair - repairBySysId(String sysId, String sourceTable)

Repair the task SLAs associated with the passed in sys_id and source table.

NameTypeDescription
sysIdstringSpecify the ID of a table that is (or extends) contract_sla, task_sla, or task.
sourceTablestringSpecify the name of a table that is (or extends) contract_sla, task_sla, or task.
TypeDescription
void 

Find problems created last month with a priority of 2.

var now_GR = new GlideRecord("problem");
now_GR.addQuery("sys_created_on", "ON", "Last Month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()");
now_GR.addQuery("priority", "2");
now_GR.query();

var repair = new SLARepair();
repair.repairBySysId(now_GR.sys_id + "",  now_GR.getRecordClassName());

SLARepair - setAuditEnabled(Boolean onOrOff)

Enables or disables auditing when running a repair.

By default, auditing is set to the value in the property com.snc.sla.repair.audit. You can override this by passing in true to enable or false to disable auditing.

NameTypeDescription
onOrOffBooleanFlag that indicates whether to enable auditing.Valid values: - true: Enable auditing. - false: Disable auditing.
TypeDescription
thisSelf-reference to allow for method chaining.
var builder = new SLARepair();
  builder.setAuditEnabled(true);

SLARepair - setRunWorkflow(Boolean onOrOff)

Enables or disables running a workflow for each of the Task SLA records being repaired.

By default, when a Task SLA is repaired the workflow is run during the repair process. To override this, you can pass in false to disable running of the workflow.

NameTypeDescription
onOrOffBooleanFlag that indicates whether to enable workflow.Valid values: - true: Enable workflow. - false: Disable workflow.
TypeDescription
thisSelf-reference to allow for method chaining.
var repair = new SLARepair();
repair.setRunWorkflow(false);

SLARepair - setValidateOnly(Boolean onOrOff)

Validates the repair request.

If false is passed in, the task SLAs are repaired. If true is passed in, calls to repair don't alter any task SLAs, they only validate the supplied parameters and generate a count of records to be repaired.

NameTypeDescription
onOrOffBooleanFlag that indicates whether to enable validation.Valid values: - true: Enable validation. - false: Disable validation.
TypeDescription
thisSelf-reference to allow for method chaining.
var repair = new SLARepair();
  repair.setValidateOnly(true);