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

SLARepair - repairByFilter(String filter, String sourceTable)

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

Table 1. Parameters
Name Type Description
filter String Encoded query that is used to retrieve a set of records from the source table.
sourceTable String Name of a table that is (or extends) contract_sla, task_sla, or task.
Table 2. Returns
Type Description
void

Example

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.

Table 3. Parameters
Name Type Description
now_GR GlideRecord GlideRecord for a table that is (or extends) contract_sla, task_sla, or task.
Table 4. Returns
Type Description
void

Example

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.

Table 5. Parameters
Name Type Description
sysId string Specify the ID of a table that is (or extends) contract_sla, task_sla, or task.
sourceTable string Specify the name of a table that is (or extends) contract_sla, task_sla, or task.
Table 6. Returns
Type Description
void

Example

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.

Table 7. Parameters
Name Type Description
onOrOff Boolean Flag that indicates whether to enable auditing.
Valid values:
  • true: Enable auditing.
  • false: Disable auditing.
Table 8. Returns
Type Description
this Self-reference to allow for method chaining.

Example

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.

Table 9. Parameters
Name Type Description
onOrOff Boolean Flag that indicates whether to enable workflow.
Valid values:
  • true: Enable workflow.
  • false: Disable workflow.
Table 10. Returns
Type Description
this Self-reference to allow for method chaining.

Example

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.

Table 11. Parameters
Name Type Description
onOrOff Boolean Flag that indicates whether to enable validation.
Valid values:
  • true: Enable validation.
  • false: Disable validation.
Table 12. Returns
Type Description
this Self-reference to allow for method chaining.

Example

var repair = new SLARepair();
  repair.setValidateOnly(true);