SLARepair - Global

The SLARepair API first deletes 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 Specify an encoded query that is used to retrieve a set of records from the source table.
sourceTable string Specify the name of a table that is (or extends) contract_sla, task_sla, or task.
Table 2. Returns
Type Description
void

Find problems created last month with a priority of 2

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

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

SLARepair - repairByGlideRecord(GlideRecord gr)

Repair the task SLAs associated with the passed in GlideRecord.

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

Find problems created last month with a priority of 2

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

Call SLA repair for the GlideRecord

var repair = new SLARepair();
repair.repairByGlideRecord(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

Find problems created last month with a priority of 2

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

var repair = new SLARepair();
while (gr.next())
    repair.repairBySysId(gr.sys_id + "",  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 with passing in true to enable or false to disable auditing.

Table 7. Parameters
Name Type Description
onOrOff Boolean Determines whether to enable or disable auditing.
Table 8. Returns
Type Description
this A self-reference to allow for method chaining.
var builder = new SLARepair();
  builder.setAuditEnabled(true);

SLARepair - setRunWorkflow(Boolean onOrOff)

This API 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 will be run during the repair process. To override this, you can pass in false to disable running of the workflow or true to enable it.

Table 9. Parameters
Name Type Description
onOrOff Boolean Determines whether to enable or disable workflow.
Table 10. Returns
Type Description
this A self-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 will be repaired. If true is passed in, calls to repair will not alter any task SLAs but only validate the supplied parameters and generate a count of records to be repaired.

Table 11. Parameters
Name Type Description
onOrOff Boolean Determines whether to enable or disable validation.
Table 12. Returns
Type Description
this A self-reference to allow for method chaining.

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