Customize the Closing of Incidents
The application provides events to customize the closing of incidents.
The following explains how to fill in (customized) fields in the process of closing the incidents, both in the closing entry that is automatically generated and, optionally, in the header of the incident itself.
On the page shown to the user when closing an incident, IDPIMG Close Incident, the OnBeforeInsertIncidentEntryWhenCloseIncident event is published so that we can subscribe to it and add more custom fields in the closing entry of incidents.
local procedure OnBeforeInsertIncidentEntryWhenCloseIncident(var TempClosingIncident: Record "IDPIMG Incident Header" temporary; var IncidentEntry: Record "IDPIMG Incident Entry")
The event is triggered just before inserting the automatically generated entry of the closing type incident, and receives as parameters a temporary record of the table "IDPIMG Incident Header (the incident being closed), and the record corresponding to the closing entry.
In the IDPIMG Incident Management codeunit, an event, OnBeforeModifyIncidentHeaderWhenCloseIncident, is triggered in the CloseIncident function, which is called when closing an incident, after the creation of the closing entry, to modify the status of the incident to Closed, so that we can subscribe to it and modify more custom fields in the incident header.
local procedure OnBeforeModifyIncidentHeaderWhenCloseIncident(var TempClosingIncident: Record "IDPIMG Incident Header" temporary; var IncidentHeader: Record "IDPIMG Incident Header")
The event is triggered just before the incident header is modified after the status change and receives as parameters a temporary record of the table "IDPIMG Incident Header (the incident being closed), and the incident header itself with the status already as Closed.
Below is an example of customization using these events, where the user, in addition to the data requested by the app by default when closing an incident (reason for closing, description, etc.), must indicate the date and time when the actual closure of the incident occurred.
The desired fields are added both in the IDPIMG Incident Entry table and, optionally, in the IDPIMG Incident Header table, on which the page for closing incidents (IDPIMG Close Incident) is based.
TipIt is recommended that, if fields in the IDPIMG Incident Entry and IDPIMG Incident Header tables are duplicated, they be as non-editable in the IDPIMG Incident Header table to be consistent with the app's closing process, which records the closing information in the incident entries. They can be added to the incident header for the convenience of data exploitation and can be added as normal fields or as FlowField fields, but in no case editable since, when an incident is closed, it can no longer be modified.
tableextension 50104 "MYPRE Incident Entry" extends "IDPIMG Incident Entry"
{
fields
{
field(50100; "Closing Date Time"; DateTime)
{
Caption = 'Date Time of the closing';
DataClassification = CustomerContent;
}
}
}
tableextension 50102 "MYPRE Incident Header" extends "IDPIMG Incident Header"
{
fields
{
field(50103; "Closing Date Time"; DateTime)
{
Caption = 'Date Time of the closing';
Editable = false;
DataClassification = CustomerContent;
}
}
}
The page shown when closing incidents, IDPIMG Close Incident, is extended by adding the new information to be filled in. The new fields, even if they were only to be filled in the Incident Entry table, must also be added in the Incident Header table, as this is the table on which the incident closing page is based.
ImportantThey should be added as variables, not as fields, so that they can be editable, since the page is displayed in Lookup mode so that the user can cancel the process of closing the incident. Therefore, in this PageExtension, in the trigger OnClosePage the value of the variables will have to be passed to the corresponding fields of Rec so that, in the following point we can use them (it cannot be done in the Validate of each column because the page is in Lookup mode).
pageextension 50106 "MYPRE Close Incident" extends "IDPIMG Close Incident"
{
layout
{
addbefore("Reason Code")
{
group("MYPRE Closing DateTime")
{
Caption = 'Closing Date Time';
field(ClosingDate; ClosingDate)
{
ApplicationArea = All;
Caption = 'Closing Date';
ToolTip = 'The real date when the incident was closed.';
}
field(ClosingTime; ClosingTime)
{
ApplicationArea = All;
Caption = 'Closing Time';
ToolTip = 'The real time when the incident was closed.';
}
}
}
}
trigger OnOpenPage()
begin
ClosingDate := Today();
ClosingTime := Time();
end;
trigger OnClosePage()
begin
Rec."Closing Date Time" := CreateDateTime(ClosingDate, ClosingTime);
end;
var
ClosingDate: Date;
ClosingTime: Time;
}
We must subscribe to two events:
OnBeforeInsertIncidentEntryWhenCloseIncident on the IDPIMG Close Incident page, to pass the value of new fields added on the incident closing dialog box to the incident closing entry that is automatically created. An error could also be thrown if any new field should be filled and is not filled before the incident is closed.
NoteThe Rec on the IDPIMG Close Incident dialog box corresponds to the incident being closed (temporary copy).
[EventSubscriber(ObjectType::Page, Page::"IDPIMG Close Incident", 'OnBeforeInsertIncidentEntryWhenCloseIncident', '', false, false)]
local procedure OnBeforeInsertIncidentEntryWhenCloseIncident(var TempClosingIncident: Record "IDPIMG Incident Header"; var IncidentEntry: Record "IDPIMG Incident Entry")
begin
IncidentEntry.Validate("Closing Date Time", TempClosingIncident."Closing Date Time");
end;
- OnBeforeModifyIncidentHeaderWhenCloseIncident of the IDPIMG Incident Management codeunit, to transfer the value of the new fields added in the closing dialog box of an incident to the header of the incident being closed, in case you want to add fields to this header to facilitate the exploitation of the closing information, even if it is redundant because it is actually saved in the closing entry.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"IDPIMG Incident Management", 'OnBeforeModifyIncidentHeaderWhenCloseIncident', '', false, false)]
local procedure OnBeforeModifyIncidentHeaderWhenCloseIncident(var TempClosingIncident: Record "IDPIMG Incident Header"; var IncidentHeader: Record "IDPIMG Incident Header")
begin
IncidentHeader.Validate("Closing Date Time", TempClosingIncident."Closing Date Time");
end;