{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1097,"path":"api-reference/server-api-reference/c_SLARepair.md","title":"SLARepair - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# SLARepair- Global\n\nThe SLARepair script include provides methods that delete the existing SLAs and then recreates them from each task's history.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## SLARepair - repairByFilter\\(String filter, String sourceTable\\)\n\nRepair the task SLAs associated with the passed-in filter and source table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|filter|String|Encoded query that is used to retrieve a set of records from the source table.|\n|sourceTable|String|Name of a table that is \\(or extends\\) contract\\_sla, task\\_sla, or task.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nRepair SLAs for problems created last month with a priority of 2.\n\n```\nvar now_GR = new GlideRecord(\"problem\");\nnow_GR.addQuery(\"sys_created_on\", \"ON\", \"Last Month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()\");\nnow_GR.addQuery(\"priority\", \"2\");\nnow_GR.query();\n\nvar repair = new SLARepair();\nrepair.repairByFilter(now_GR.getEncodedQuery(), now_GR.getRecordClassName());\n```\n\n## SLARepair - repairByGlideRecord\\(GlideRecord now\\_GR\\)\n\nRepair the task SLAs associated with the passed in GlideRecord.\n\n|Name|Type|Description|\n|----|----|-----------|\n|now\\_GR|GlideRecord|GlideRecord for a table that is \\(or extends\\) contract\\_sla, task\\_sla, or task.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nRepair SLAs for problems created last month with a priority of 2.\n\n```\nvar now_GR = new GlideRecord(\"problem\");\nnow_GR.addQuery(\"sys_created_on\", \"ON\", \"Last Month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()\");\nnow_GR.addQuery(\"priority\", \"2\");\nnow_GR.query();\n\nvar repair = new SLARepair();\nrepair.repairByGlideRecord(now_GR);\n```\n\n## SLARepair - repairBySysId\\(String sysId, String sourceTable\\)\n\nRepair the task SLAs associated with the passed in sys\\_id and source table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|sysId|string|Specify the ID of a table that is \\(or extends\\) contract\\_sla, task\\_sla, or task.|\n|sourceTable|string|Specify the name of a table that is \\(or extends\\) contract\\_sla, task\\_sla, or task.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nFind problems created last month with a priority of 2.\n\n```\nvar now_GR = new GlideRecord(\"problem\");\nnow_GR.addQuery(\"sys_created_on\", \"ON\", \"Last Month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()\");\nnow_GR.addQuery(\"priority\", \"2\");\nnow_GR.query();\n\nvar repair = new SLARepair();\nrepair.repairBySysId(now_GR.sys_id + \"\",  now_GR.getRecordClassName());\n\n```\n\n## SLARepair - setAuditEnabled\\(Boolean onOrOff\\)\n\nEnables or disables auditing when running a repair.\n\nBy 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.\n\n<table id=\"table_p1z_b1c_sr\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nonOrOff\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to enable auditing.Valid values:\n\n-   true: Enable auditing.\n-   false: Disable auditing.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|this|Self-reference to allow for method chaining.|\n\n```\nvar builder = new SLARepair();\n  builder.setAuditEnabled(true);\n\n```\n\n## SLARepair - setRunWorkflow\\(Boolean onOrOff\\)\n\nEnables or disables running a workflow for each of the Task SLA records being repaired.\n\nBy 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.\n\n<table id=\"table_f32_21c_sr\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nonOrOff\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to enable workflow.Valid values:\n\n-   true: Enable workflow.\n-   false: Disable workflow.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|this|Self-reference to allow for method chaining.|\n\n```\nvar repair = new SLARepair();\nrepair.setRunWorkflow(false);\n```\n\n## SLARepair - setValidateOnly\\(Boolean onOrOff\\)\n\nValidates the repair request.\n\nIf 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.\n\n<table id=\"table_xlw_c1c_sr\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nonOrOff\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to enable validation.Valid values:\n\n-   true: Enable validation.\n-   false: Disable validation.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|this|Self-reference to allow for method chaining.|\n\n```\nvar repair = new SLARepair();\n  repair.setValidateOnly(true);\n```\n\n"}}