Custom Placeholder Objects

Custom placeholder ticket definitions must contain a ticket object. This topic presents the attributes and functions for this object.

Examples

The following examples use the ticket object.

This example returns the date in UTC format:

def ticket_utc(ticket, **kwargs):
    #example:'2021-01-22T22:40:23.054-04:00'
    format = '%Y-%m-%dT%H:%M:%S.%f%z'
    dt_string = ticket.create_date 
    dt = datetime.strptime(dt_string,format)
    return datetime.strftime(dt.astimezone(UTC),'%Y-%m-%d %H:%M:%S')

This example returns the step ID:

def current_step_id(ticket, **kwargs):
     try:
           step = ticket.get_current_step()
           return step.id
     except Exception:
           return ''

Besides using the ticket object, you can import standard python modules if you want to use them; however, this is not required. For example:

from dateutil.tz import UTC
from datetime import datetime

Ticket Object

Attributes

Attribute

Description

Type

Possible Values

id SecureChange ticket ID.

Integer

 

subject Subject of the ticket.

String

 

requester Name of the requester.

String

 

requester_id Ticket requester ID.

Integer

 

priority Priority of the request.

String

  • Critical

  • High

  • Normal

  • Low

status Status of the ticket.

String

  • In Progress

  • Ticket Rejected

  • Ticket Closed

  • Ticket Canceled

  • Ticket Resolved

domain_name Ticket domain name.

String

 

sla_status Ticket's current SLA status.

String

  • OK

  • Warning

  • Alert

  • Escalation

  • NA

sla_outcome

Outcome of the SLA.

String

  • Unknown

  • Met

  • Overdue

  • NA

workflow

Workflow used for this ticket.

String

 

step_list

List of step objects.

Step object

 

current_step

Current step in workflow.

String

 

comments

Comments in the ticket.

String

 

create_date

Ticket creation date.

String

 

update_date

Last update date for the ticket.

String

 

Functions

Function

Description

Possible Values

get_comments()

Gets all comments in the ticket

 

get_current_step()

Gets the current step in the ticket as an object. If the ticket is not in progress, returns an error.

 

get_step_by_name(step_name)

Returns ticket step object by step name from the steps in the ticket that have been processed already.

 

get_step_by_id(step_id)

Returns a step object from the ticket based on the step ID.

 

get_step_by_index(step_index)

Returns a step object according to the step index.

 

get_last_step()

Returns a step object from the last step in the ticket.

 

get_first_step()

Returns a step object from the first step in the ticket.

 

get_last_task()

Returns a task object in the ticket.

 

is_closed()

Indicates whether the ticket is closed.

  • True

  • False

is_cancelled()

Indicates whether the ticket is canceled.

  • True

  • False

is_rejected()

Indicates whether the ticket is rejected.

  • True

  • False

is_resolved()

Indicates whether if the ticket is resolved.

  • True

  • False

is_in_progress()

Indicates whether if the ticket is in progress.

  • True

  • False

Step Object

Actions

Attribute

Description

Type

Possible Values

id Step ID Integer

 

name Step name String

 

redone Indicates whether the task was redone. Boolean
  • True

  • False

skipped Indicates whether the task was skipped. Boolean
  • True

  • False

task_list

List of task objects.

Task object

 

Functions

Function

Description

Possible Values

get_task get_last_task() Returns the last task in the step.

 

is_skipped() Indicates whether the task is skipped.
  • True

  • False

Task Object

Actions

Attribute

Description

Type

Possible Values

assignee_id ID of individual assigned the task. Integer

 

assignee Name of the individual assigned the task. String

 

field_list List of field objects. Field object

 

ID Task ID. Integer

 

status

Status of the task.

String

  • In Progress

  • Ticket Rejected

  • Ticket Closed

  • Ticket Canceled

  • Ticket Resolved

Functions

Function

Description

get_field_list_by_type(field_type)

Returns list of field objects. Supported field types in SecureChange include:

  • "approve_reject"'

  • "checkbox"

  • "date"

  • "drop_down_list"

  • "hyperlink"

  • "manager"

  • "multiple_selection"

  • "multi_access_request"

  • "multi_group_change"

  • "multi_hyperlink"

  • "multi_network_object"

  • "multi_service"

  • "multi_server_decommission_request"

  • "multi_target"

  • "multi_text_field"

  • "multi_text_area"

  • "rule_decommission"

  • "text_field"

  • "text_area"

  • "time"

Field Object

Actions

Attribute

Description

Type

Possible Values

@xsi.type Field type String

 

id Field ID Integer

 

name Field name String

 

read_only Indicates whether the field is read-only

Boolean

  • True

  • False

Functions

Function

Description

field_type() Returns the field type.
get_field_value() Returns the value of the field.
get_access_requests() Returns list of access requests.