Workflows
Establish a System for Resolving Support Tickets
The basic Support Ticket application can only create and edit tickets. Now we can add a mechanism to see the progress of a ticket and identify who is working on it.
NOTE: This tutorial is built upon the foundation of the Support Ticket application.
1. Define Ticket Status codebook
- Type
Ctrl + Shift + C
; click Codebook - Set
Name
to: Ticket Status - Verify that
Create Display Attribute
is set to: Name - Click
Finish
— - On the Ticket Status codebook, click
Edit Entries
- Copy and paste the entries from the table below (without table headers)
Code | Name |
---|---|
NEW | New |
IN_PROGRESS | In Progress |
CLOSED | Closed |
- Click
OK
- Save changes:
Ctrl + S
2. Update your Ticket entity
- Go to Data > Entities and double-click Ticket
- In Data Definition > References, click
Add New Reference
- Set
Reference Type
to: Codebook - Set
Target
to: TicketStatus - Set
Please select default values
to: NEW - Click
Create References
— - In Data Definition > Attributes, click
Add New Attribute
- Set the following new attributes (i.e., Attribute name — Type):
Date In Progress — Date and Time (mark Allow null)
Date Closed — Date and Time (mark Allow null)
Assigned To — User
Description Of Resolution — Rich-text Markdown - Click
Create Attributes
- Save changes:
Ctrl + S
3. Add Workflow
State machines represent workflow transitions and conditions.
- Go to Business > State Machines, click
(+)
OR ClickCtrl + Shift + C
and, in the Business section, click State Machine - Set
Name
to: Ticket Status - Set
Entity
to: Ticket - Set
Codebook Representing States
to: TicketStatus - Click
Finish
4. Add Transitions
In the Ticket Status state machine,
- Click
Add New Transition
- Set
Origin State
to NEW. - Set
Destination State
to IN_PROGRESS - Mark
Transition Handler
. Click in the box. Copy and paste:
(ticket, db, ctx) =>
{
ticket.DateInProgress = DateTime.Now;
}
- Click
OK
—
Follow the same steps to establish each additional transition. - Click
Add New Transition
- Set
Origin State
to: IN_PROGRESS. - Set
Destination State
to: CLOSED - Mark
Transition Handler
. Copy and paste:
(ticket, db, ctx) =>
{
ticket.DateInProgress = DateTime.Now;
}
- Click
OK
—
Only a ticket with a Description of Resolution can be closed. Under the IN_PROGRESS->CLOSED transition, clickAdd New Transition Condition
- Set
Title of Condition
to Description of Resolution Provided - Verify that
Severity
is set to: Error - Click in the
Condition
box. Copy and paste:
(ticket, db, ctx) => !string.IsNullOrEmpty(ticket.DescriptionOfResolution)
- Click
OK
- Click
OK
- Save changes:
Ctrl + S
5. Add State Machine to Ticket Entity
- Open the Ticket entity (Go to Data > Entities and double-click Ticket.)
- Click the
Settings
tab. In the User Interface section, setState Machine
to: Ticket Status - Set
State Codebook Reference
to: TicketStatus (TicketStatus) - Save changes:
Ctrl + S
6. Modify your Ticket Detail Page
- Go to UI > Entity Pages and double-click Ticket Detail
- In the top Layout section, click
Edit Layout
- Add the following data fields: Ticket Status, Created Date, Date In Progress, Date Closed, Assigned To, Created By and Description of Resolution.
- Drag and drop the data fields around inside the two columns to the desired layout
—
Set all of the Date data fields to Read Only. Click on each of the following titles one at a time: Created Date, Date In Progress, Date Closed - Mark
Enabled Expression
and type: false - Click
OK
—
Establish that Date In Progress and Date Closed must have values. - Click Date In Progress
- Set
Visible Expression
to:
(ticket, db, ctx) => ticket.DateInProgress.HasValue
- Click
OK
- Click Date Closed
- Set
Visible Expression
to:
(ticket, db, ctx) => ticket.DateClosed.HasValue
- Click
OK
—
Click DescriptionOfResolution - In the Validations section, click the
Magic Wand
; select: Not empty string - On the Can’t be empty entry, click the Edit icon
- Verify that
Valid Condition
shows the following: !String.IsNullOrEmpty(ticket.DescriptionOfResolution) - Mark
Is Applicable
. Copy and paste:
ticket.TicketStatus == TicketStatus.IN_PROGRESS
- Click
OK
- Click
OK
- Save changes:
Ctrl + S
7. Show State Machine Buttons
- Continue on the Ticket Detail page (UI > Entity Pages, double-click Ticket Detail.)
- Click the
Settings
tab. In the UI section, clickShow State Change Toolbar
- Change the value to: True
- Save changes:
Ctrl + S
8. Update List page
The main list page should include this new information.
- In UI > Entity Pages, double-click Ticket list
- Click the Columns tab (if necessary).
- Add TicketStatus (TicketStatus)
- Add other new columns and organize the columns for the desired layout
- Click
Close
- Save changes:
Ctrl + S