Skip to main content

Ticketing System Condition

Overview​

You can add a Ticketing System Event Condition to your package so that your package is triggered based on the changes made to a ticket in your ticketing system. This may include adding a new ticket or updating an existing ticket.

One of the example scenarios where this condition is currently used in Pia is in the Triage package. The Triage package is triggered when a new ticket is created, or an existing ticket is updated in a specified board in the ticketing system. When the package runs, tickets are then triaged based on the rules and conditions specified in the package.

The Ticketing System condition can be located in the list of conditions in the package editor: Ticketing System Condition

Here is an example of a basic package that uses Ticketing System condition:

# Pia Automation Package
conditions:

- name: 'system_ticketing'
entity: 'ticket'
action: 'created,updated'
filter: 'ticket.priority.name == "Priority 1 - Critical"'
instancing: 'single'


steps:

- task: cw_get_ticket_by_id
inputs:
ticket_id: =system_ticketing.ticket_id

- task: inline_powershell
inputs:
ticketInfo: =system_ticketing.ticket_id
script: |
Write-Host $ticketInfo

In this example, the package is triggered when a new ticket is created in the ticketing system. The package will then move the ticket to either 'Service Request' board or 'Incident' board based on the rules specified.

Condition Behavior​

When a ticket is updated or created in the ticketing system which means that the user has saved the ticket record in the ticketing system, this will trigger the package execution as long as the filter criteria of the ticketing system event condition is met.

The ticketing system may also perform its own workflow actions on a ticket which may cause additional update events to be generated from the ticketing system after the user saves the ticket. To avoid executing multiple instances of a package for a single save action, you can use a combination of the instancing, blocking and delay seconds input properties to control this behavior.

The Ticketing System Event Condition is only active in Live mode, not in sandbox mode. To test your package in sandbox mode, you will need to use the "Test Execute" feature or temporarily add a chat_interaction condition for use via the chatbot.

Input Properties​

Use properties to modify the behavior of the condition.

Property Name: entity
Property Required: Yes
Property Options: ticket, opportunity, company
Property Description: The name of the entity to monitor for events which may trigger this package to execute

entity

Property Name: action
Property Required: Yes
Property Options: created, updated, deleted
Property Description: The action on the entity which may trigger this package to execute

action

Property Name: filter
Property Required: No
Property Description: Use c# syntax to create a logic condition which evaluates to true or false. Refer to the "Filter Condition Expressions" heading at the bottom of this article for examples and details.

filter

Property Name: instancing
Property Required: No
Property Options: 'single' or 'multiple'
Default Option: 'multiple'
Property Description: Specify single if you only want this package to run if there isn't already one running for the entity. This can be used to prevent multiple packages from starting at the same time for a single ticket save events if multiple events are received from the ticketing system in a short timespan for the same ticket (or entity).

instancing

Property Name: blocking
Property Required: No
Property Options: 'true' or 'false'
Default Value: 'false'
Property Description: Blocking will make sure only one instance of this package can be run at a time, regardless of the entity id. Any pending events will be queued until the previous instance of the package completes (in other words, blocking will still process the event, it will just be delayed. This is unlike the instancing property which will ignore secondary events while package is already running).

blocking

Property Name: delay_seconds
Property Required: No
Default Value: 0
Property Description: A delay seconds property can be used to delay the evaluation of the filter criteria and execution of the package. For example, in the case where multiple events are received from a single Save action in your ticketing system, if a workflow is running in your ticketing system on your ticket, you may want to wait until that workflow completes before evaluating your filter criteria in case the workflow modified properties which your filter criteria relies on.

delay_seconds

Output Properties​

Here are the output properties which the Ticketing System condition makes available.

Property Name: ticketing_client_id
Property Description: The client id of the client from the ticketing system event

Property Name: client_id
Property Description: The Pia client id of the client for which the package is running

Property Name: opportunity_id
Property Description: The id of the opportunity event for which this package is running

Property Name: ticket_id
Property Description: The id of the ticket event for which this package is running

Filter Condition Expressions​

By using the filter input property of the ticketing_system condition, you can limit the circumstances for which your automation will be triggered by a new ticket or ticket update. This is extremely useful for custom automation you create, where you want to do something for a specific condition or for the triage automation where you want to only triage tickets under limited conditions.

Here is a non-exhaustive list of examples you may wish to take and customize for yourself:

Filter TextDescription
filter: '(ticket.board.name == "Service Desk" && ticket.status.name == "New") \|\| (ticket.board.name == "Dispatch" && (ticket.status.name == "New (Portal)" \|\| (ticket.status.name == "New (Email)"))'Match tickets on the Service Desk board in the "New" status or where the ticket is on the dispatch board in either the "New(Portal)" or "New(Email)" status.
filter: 'Regex.Match(ticket.summary, "^Backup for .* failed$").Success'Match tickets where the ticket summary/subject is in the pattern "Backup for XYZ failed".
filter: 'ticket.closedDate != null'Match tickets which have been closed (Have a closed date)
filter: 'ticket.parentTicketId == null'Match tickets which are not a child ticket (do not have a parent ticket)
filter: '((IEnumerable<dynamic>)ticket?.customFields)?.Where(c => c.caption == "Pia Serviceable" && c.value == "Yes").Count() > 0'Match tickets where the custom field "Pia Serviceable" is set to "Yes"
filter: 'ticket.priority == null'Match tickets where the priority of the ticket is not set

Depending on which entity you use (opportunity, ticket, company) you will be able to access certain objects and their properties:

EntityAvailable Objects
ticketticket,company
companycompany
opportunityN/A (Not Yet Supported)

Each object you can use in the filter has properties which you can check. These properties are supported across all ticketing systems which Pia supports. The properties are as follows:

EntityPropertySub-PropertyExpressionNotes
ticketid (text)ticket.idThe ticket id (e.g. 34556)
ticketsummary (text)ticket.summaryThe ticket subject/title/summary
ticketboardid (number)ticket.board.idLookup value associated to the ticket
ticketboardname (text)ticket.board.nameLookup value associated to the ticket
tickettypeid (number)ticket.type.idLookup value associated to the ticket
tickettypename (text)ticket.type.nameLookup value associated to the ticket
ticketsubTypeid (number)ticket.subType.idLookup value associated to the ticket
ticketsubTypename (text)ticket.subType.nameLookup value associated to the ticket
ticketitemid (number)ticket.item.idLookup value associated to the ticket
ticketitemname (text)ticket.item.nameLookup value associated to the ticket
ticketcontactid (number)ticket.contact.idLookup value associated to the ticket
ticketcontactname (text)ticket.contact.nameLookup value associated to the ticket
ticketownerid (number)ticket.owner.idLookup value associated to the ticket
ticketownername (text)ticket.owner.nameLookup value associated to the ticket
ticketcompanyid (number)ticket.company.idLookup value associated to the ticket
ticketcompanyname (text)ticket.company.nameLookup value associated to the ticket
ticketpriorityid (number)ticket.priority.idLookup value associated to the ticket
ticketpriorityname (text)ticket.priority.nameLookup value associated to the ticket
ticketstatusid (number)ticket.status.idLookup value associated to the ticket
ticketstatusname (text)ticket.status.nameLookup value associated to the ticket
ticketsourceid (number)ticket.source.idLookup value associated to the ticket
ticketsourcename (text)ticket.source.nameLookup value associated to the ticket
ticketdisplayId (text)ticket.displayId(AutoTask and Service Now Only) this is the "friendly id" of a ticket (i.e. T20231027.001)
ticketcustomFields (collection)captionticket.customFields[0].caption(ConnectWise and Halo PSA Only) this is the display name of the custom field
ticketcustomFields (collection)valueticket.customFields[0].value(ConnectWise and Halo PSA Only) This is the value of the custom field
ticketclosedDate (nullable date)ticket.closedDate
ticketparentTicketId (nullable number)ticket.parentTicketId