Customize the No. Series for Incidents
The application provides events to customize the No. Series to be used when creating incidents.
Manually Created Incidents
When manually creating an incident, it is numbered, by default, using the series specified in iDynamics Incident Management Setup; however, you can select another series from those defined in the system through the AssistEdit (3 dots to the right of the No. field).
If you would like to modify the behavior of the AssistEdit, you can use the OnBeforeAssistEdit event, triggered by the IDPIMG Incident Header table.
local procedure OnBeforeAssistEdit(var IncidentHeader: Record "IDPIMG Incident Header"; OldIncidentHeader: Record "IDPIMG Incident Header"; var IsHandled: Boolean; var Result: Boolean)
The event is triggered at the beginning of the function, receiving as parameters:
- IncidentHeader: header of the incident with the No. already modified by the one subscribing to the event.
- OldIncidentHeader: header of the incident as it is before clicking on the 3 dots to modify the No. Series to be used to number the incident.
- IsHandled: it must be set to true to indicate that it has been customized (in case we have subscribed to the event and we have modified the No.*) and we do not want the default code to be executed.
Incidents Created from Documents
When an incident is reported from a document, the user does not have the ability to change the series to be applied. If you wish to use a different series than the one specified in iDynamics Incident Management Setup, you have the OnBeforeGetNoSeriesCode event available, which is triggered by the IDPIMG Incident Header table.
local procedure OnBeforeGetNoSeriesCode(var IncidentHeader: Record "IDPIMG Incident Header"; var NewNoSeriesCode: Code[20]; var Handled: Boolean)
The event is triggered at the beginning of the function, receiving as parameters:
- IncidentHeader: header of the incident.
- NewSeriesCode: the No. Series to be used for numbering the incident must be returned.
- Handled: it must be set to true to indicate that it has been customized (if we have subscribed to the event and we have modified the code that handles the series) and we do not want the default code to be executed.
The following is an example of customization that consists of applying a different series for the incidents that are created from the service documents. The series for these documents is defined by adding a custom field in the iDynamics Incident Management configuration.
- A field has been added in the iDynamics Incident Management configuration (IDPIMG Incidents Setup) to indicate the series to be used for incidents coming from service documents.
tableextension 50105 "MYPRE Incident Setup" extends "IDPIMG Incidents Setup"
{
fields
{
field(50100; "MYPRE Service Incident Nos."; Code[20])
{
Caption = 'Service Incident Nos.';
TableRelation = "No. Series".Code where("MYPRE Incident Series" = const(true));
DataClassification = CustomerContent;
}
}
}
pageextension 50108 "MYPRE Incident Setup" extends "IDPIMG Incidents Setup"
{
layout
{
modify("Incident Nos.")
{
Caption = 'Default Incident Nos.';
}
addlast(General)
{
field("MYPRE Service Incident Nos."; Rec."MYPRE Service Incident Nos.")
{
ApplicationArea = All;
ToolTip = 'The series that will be used for incidents generated from service documents.';
}
}
}
}
- The creation of incidents from source documents is customized so that, in the case that they are generated from service documents, they fill the field "No. Series" of the incident (field of the iDynamics Incident Management app) with the new field created in the previous point in the app configuration. (example made only for service orders).
// ***** CUSTOMIZATION TO ADD MORE FIELDS WHEN CREATING INCIDENTS AUTOMATICALLY *****
[EventSubscriber(ObjectType::Page, Page::"IDPIMG Create Incident", 'OnBeforeCreateIncidentHeaderFromSource', '', false, false)]
local procedure OnBeforeCreateIncidentHeaderFromSource(var TempIncSourceDoc: Record "IDPIMG Inc. Source Doc.";
var IncidentHeader: Record "IDPIMG Incident Header")
var
ServiceHeader: Record "Service Header";
IncidentSetup: Record "IDPIMG Incidents Setup";
begin
case TempIncSourceDoc."Document Type" of
TempIncSourceDoc."Document Type"::"Service Order":
begin
if IncidentSetup.Get() then
if IncidentSetup."MYPRE Service Incident Nos." <> '' then
IncidentHeader.Validate("No. Series", IncidentSetup."MYPRE Service Incident Nos.");
end;
end;
end;
- We must subscribe to the OnBeforeGetNoSeriesCode event of the IDPIMG Incident Header table so that the incident is generated with the desired No. Series: the one configured for service documents if the incident comes from a service document or the default serial number for the rest of the documents.
// ***** CUSTOMIZATION OF INCIDENT NO. SERIES USED WHEN CREATING INCIDENTS AUTOMATICALLY *****
[EventSubscriber(ObjectType::Table, Database::"IDPIMG Incident Header", 'OnBeforeGetNoSeriesCode', '', false, false)]
local procedure OnBeforeGetNoSeriesCode(var IncidentHeader: Record "IDPIMG Incident Header";
var NewNoSeriesCode: Code[20]; var Handled: Boolean)
var
NoSeries: Record "No. Series";
NoSeriesLine: Record "No. Series Line";
begin
// Use a different No. Series depending on the type of source document.
if IncidentHeader."No. Series" <> '' then begin
NewNoSeriesCode := IncidentHeader."No. Series";
Handled := true;
end;
end;
The No. Series field in the incident header table is automatically filled in when a record is inserted if the No. is blank or when a different series is selected with the AssistEdit, but it is not shown to the user in any case.
To fill it in, a local function GetNoSeriesCode is called where the OnBeforeGetNoSeriesCode event has been created so that,
- If someone has subscribed and set the Handled = True, it returns the series they have customized.
- Otherwise, it returns the series specified by default in iDynamics Incident Management Setup.