Skip to main content

Creating the OnEndSession Method

We can add a new class method named OnEndSession to the Cinema.UtilsOpens in a new tab class by simply adding the following text to its class definition within the class editor window. Alternatively, you can use the New Method wizard.

—Utils.OnEndSession—
Utils.OnEndSession
ClassMethod OnEndSession()
{
     If $data(%session.Data("Order")) {
        // Delete the incomplete order
        Do ##class(Cinema.TicketOrder).%DeleteId(%session.Data("Order"))
         Kill %session.Data("Order")
    }
    Quit
}

The main thing this code does is to delete the incomplete TicketOrder object from the database. (The related TicketItem objects are deleted automatically when their TicketOrder object is deleted.)

FeedbackOpens in a new tab