{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":33599,"path":"it-service-management/service-level-management/t_DefineANewSLAConditionRule.md","title":"Create a custom SLA condition rule","bundle":null,"doc_type":null,"release":"australia","body":"\n# Create a custom SLA condition rule\n\nYou can create custom SLA condition rules to determine whether an SLA should attach, pause, complete, reattach, or cancel. SLA condition classes contain script to define processing for an SLA condition rule. Create an SLA condition rule after the SLA condition class is defined.\n\n## Before you begin\n\nRole required: admin\n\n## Procedure\n\n1.  Define an SLA Condition Class.\n\n    Navigate to **System Definition** &gt; **Script Includes** and click **New**.\n\n    Within the script in the SLA Condition Class, provide methods to modify one or more of the default SLA transitions \\(attach, pause, complete, reattach, cancel\\), defining the conditions for SLA processing. For example, the **attach** method defines when an SLA is created and attached to a task. The methods need to test a condition, referencing the condition fields on the SLA Definition form.\n\n2.  Create an SLA Condition Rule.\n\n    1.  Navigate to **Service Level Management** &gt; **SLA Condition Rules** and click **New**.\n\n    2.  Name the SLA Condition Rule.\n\n    3.  Select the Script Include defined above in the **Class Name** reference field.\n\n\n## Example of an SLA Condition Class\n\nFor example, including the following method in an SLA Condition Class attaches the SLA if its condition matches the SLA's `start_condition` field:\n\n```\nattach: function() {\n      return (this._conditionMatches(this.sla.start_condition));\n   },\n```\n\nThe following is an example which shows the format of a script include that would extend the SLAConditionBase class and provide methods for each of the SLA transitions:\n\n```\nvar SLAConditionLocal = Class.create();\n \nSLAConditionLocal.prototype = Object.extendsObject(SLAConditionBase, {\n \n   attach: function() {\n     // insert script here\n   },\n \n   pause: function() {\n     // insert script here\n   },\n \n   complete: function() {\n     // insert script here\n   },\n \n   reattach: function() {\n     // insert script here\n   },\n \n   cancel: function() {\n     // insert script here\n   },\n});\n```\n\n**Parent Topic:**[Extend SLA condition rules](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-service-management/service-level-management/c_ExtendSLAConditionRules.md)\n\n"}}