@servicenow/sdk - v4.7.0
    Preparing search index...
    • Creates an SLA definition with conditional field requirements.

      Parameters

      • config: Sla

        The SLA configuration object

      Returns Sla

      The SLA configuration

      The SLA plugin enforces build-time validation rules where field requirements depend on other field values:

      Duration Type Validations:

      • When durationType is empty (user specified duration): duration is mandatory, and schedule is mandatory when scheduleSource is "sla_definition". The conditions.pause, conditions.resume, and whenTo.resume fields are allowed.
      • When durationType is a relative duration: duration, conditions.pause, conditions.resume, and whenTo.resume are restricted (warning). Values from existing SLA definitions will be preserved but cannot be modified.

      Schedule Source Validations:

      • When scheduleSource is "no_schedule": schedule, timezoneSource, timezone, and scheduleSourceField are restricted (warning). The schedule field is automatically set to a default value.
      • When scheduleSource is "task_field": schedule and duration are restricted (warning), and scheduleSourceField is mandatory.
      • When scheduleSource is "sla_definition" (default): schedule is mandatory.

      Retroactive Start Validations:

      • When retroactive.start is false or not set: retroactive.setStartTo and retroactive.pause are restricted (warning).
      • When retroactive.start is true: retroactive.setStartTo is mandatory, and retroactive.pause is allowed.
      • When retroactive.start is true AND durationType is a relative duration: retroactive.pause is restricted (warning).

      Condition Field Validations:

      • When timezoneSource is "sla.timezone": the timezone field is allowed. Otherwise, it is restricted (warning).
      • When whenTo.resume is "no_match": conditions.resume is restricted (warning).
      • When whenTo.cancel is not "on_condition": conditions.cancel is restricted (warning).
      // Basic SLA with user specified duration
      Sla({
      $id: Now.ID['incident-priority-1-sla'],
      name: 'Priority 1 Incident Response',
      table: 'incident',
      duration: Duration({ hours: 4 }),
      schedule: 'schedule-sys-id',
      conditions: {
      start: 'priority=1',
      stop: 'state=6',
      },
      })

      // SLA with relative duration
      Sla({
      $id: Now.ID['incident-relative-sla'],
      name: 'Relative Duration SLA',
      table: 'incident',
      durationType: 'relative-duration-sys-id',
      schedule: 'schedule-sys-id',
      // Note: duration, conditions.pause, conditions.resume, whenTo.resume are restricted
      })