These events can be used to modify Business Central data before they are transferred into our simulation (SIM) data. This provides a flexible way for partners and customers to include additional data, such as values from flow fields, during the transfer process.
Standard Business Central flow fields (FieldClass = FlowField) are calculated dynamically and are not automatically evaluated during the data transfer into the SIM tables. Therefore, by default, these values are not included in the simulation. However, with the help of the OnBeforeTransfer events, these fields can be manually calculated and populated during the transfer. This enables meaningful usage of such data, for example, in tooltips, bar labels, and table text, within the visual planning interface.
The BC enhancements done by the partner:
tableextension 60002 "MCExtension" extends "Machine Center"
{
fields
{
//Examples how to calculate BC data
// Count("Machine Center" WHERE("No." = FIELD("No.")));
// Count(<DestinationTable> [WHERE (<TableFilters>)])
// Sum(<DestinationTable>.<DestinationFieldName> [WHERE(<TableFilters>)])
// Average(<DestinationTable>.<DestinationFieldName> [WHERE(<TableFilters>)]) |
// Min(<DestinationTable>.<DestinationFieldName> [WHERE(<TableFilters>)]) |
// Max(<DestinationTable>.<DestinationFieldName> [WHERE(<TableFilters>)]) |
// Lookup(<DestinationTable>.<DestinationFieldName> [WHERE(<TableFilters>)])
//This field already exists in BC
field(60000; "Capacity (CustomDefinition)"; Decimal)
{
CalcFormula = Sum("Calendar Entry"."Capacity (Effective)" WHERE("Capacity Type"
= CONST("Machine Center"), "No." = FIELD("No."),
"Work Shift Code" = FIELD("Work Shift Filter"),
Date = FIELD("Date Filter")));
Caption = 'Capacity (CustomDefinition)';
DecimalPlaces = 0 : 5;
Editable = false;
FieldClass = FlowField;
}
}
}
The SIM tables enhancements done by the partner
tableextension 60003 "MCSIMExtension" extends "NETVPS SIMMchnCntr"
{
fields
{
field(60000; "Capacity (CustomDefinition)"; Decimal)
{
Caption = 'Capacity (CustomDefinition)';
DecimalPlaces = 0 : 5;
Editable = false;
FieldClass = Normal;
}
}
}
Please note that the data field numbers have to be identical.
The events occur on loading or reloading and are structured as follows:
OnBeforeTransferBCTableName(pClientGuid: Guid; var pBCTableNameRecord: Record “BCTableName” var pHandled: Boolean)
The event delivers the BC record to be transferred. Then, an own or an already existing FlowFilter can be set, and FlowField values can be calculated – the new value will be stored in the record. After this, the VJS will process the record and transfer it to the SIM tables. The calculated value is then used as well, but it is also possible to describe “nonFlowFields” so that the BC data for the simulation can be modified.
Example 1
[EventSubscriber(ObjectType::Codeunit, Codeunit::"NETVPS IntegrationMgmt",
'OnBeforeTransferMachineCenter', '', false, false)]
local procedure handleOnBeforeTransferMachineCenter(pClientGuid: Guid; var
pMachineCenter: Record "Machine Center"; var pHandled: Boolean)
var
adate: Date;
begin
if gEventHandlingActivate then begin
adate := WorkDate();
pMachineCenter."Date Filter" := adate;
pMachineCenter.SetRange("Date Filter", adate);
pMachineCenter.SetRange("Work Shift Filter", '1');
if pMachineCenter.CalcFields("Capacity (CustomDefinition)") then;
pHandled := true;
end;
end;
Example 2
//This field is calculated by ourselves
tableextension 60004 "WCExtension" extends "Work Center"
{
fields
{
field(60001; "WCNoOfMCs (CustomDefinition)"; Integer)
{
CalcFormula = Count("Machine Center" WHERE("Work Center No." = FIELD("No.")));
Caption = 'WC Count of MCs per WC';
Editable = false;
FieldClass = FlowField;
}
}
}
tableextension 60005 "WCSIMExtension" extends "NETVPS SIMWrkCntr"
{
fields
{
field(60001; "WCNoOfMCs (CustomDefinition)"; Integer)
{
Caption = 'WC Count of MCs per WC';
Editable = false;
FieldClass = Normal;
}
}
}
[EventSubscriber(ObjectType::Codeunit, Codeunit::"NETVPS IntegrationMgmt",
'OnBeforeTransferWorkCenter', '', false, false)]
local procedure handleOnBeforeTransferWorkCenter(pClientGuid: Guid; var pWorkCenter:
Record "Work Center"; var pHandled: Boolean)
begin
if gEventHandlingActivate then begin
pWorkCenter.SetRange("No.", pWorkCenter."No.");
if pWorkCenter.CalcFields("WCNoOfMCs (CustomDefinition)") then;
pHandled := true;
end;
end;
These data can be displayed in tooltip, bar, or table:
The events in detail:
OnBeforeTransferMachineCenter
This event occurs on loading a machine center
[IntegrationEvent(/*IncludeSender*/false, /*GlobalVarAccess*/false)]
procedure OnBeforeTransferMachineCenter(pClientGuid: Guid;
var pMachineCenterRecord: Record “Machine Center”; var pHandled: Boolean)
|
|
Data type |
Description |
|
Parameter: pClientGuid |
Guid |
This value is used for the global identification of VPS Control-AddIn on a page. |
|
var pMachineCenterRecord |
Record |
The machine center to be loaded. |
|
var pHandled |
Boolean |
The event will be handled if it returns true |
OnBeforeTransferProdOrder
This event occurs on loading a production order.
[IntegrationEvent(/*IncludeSender*/false, /*GlobalVarAccess*/false)]
procedure OnBeforeTransferProdOrder(pClientGuid: Guid;
var pProdOrderRecord: Record “Production Order”; var pHandled: Boolean)
|
|
Data type |
Description |
|
Parameter: pClientGuid |
Guid |
This value is used for the global identification of VPS Control-AddIn on a page. |
|
var pProdOrderRecord |
Record |
The production order to be loaded. |
|
var pHandled |
Boolean |
The event will be handled if it returns true |
OnBeforeTransferProdOrderLine
This event occurs on loading a production order line.
[IntegrationEvent(/*IncludeSender*/false, /*GlobalVarAccess*/false)]
procedure OnBeforeTransferProdOrderLine(pClientGuid: Guid;
var pProdOrderLineRecord: Record “Prod. Order Line”; var pHandled: Boolean)
|
|
Data type |
Description |
|
Parameter: pClientGuid |
Guid |
This value is used for the global identification of VPS Control-AddIn on a page. |
|
var pProdOrderLineRecord |
Record |
The production order line to be loaded. |
|
var pHandled |
Boolean |
The event will be handled if it returns true |
OnBeforeTransferProdOrderRoutingLine
This event occurs on loading a production order routing line.
[IntegrationEvent(/*IncludeSender*/false, /*GlobalVarAccess*/false)]
procedure OnBeforeTransferProdOrderRoutingLine(pClientGuid: Guid;
var pProdOrderRoutingLineRecord: Record “Prod. Order Routing Line”; var pHandled: Boolean)
|
|
Data type |
Description |
|
Parameter: pClientGuid |
Guid |
This value is used for the global identification of VPS Control-AddIn on a page. |
|
var pProdOrderRoutingLineRecord |
Record |
The production order routing line to be loaded. |
|
var pHandled |
Boolean |
The event will be handled if it returns true |
OnBeforeTransferWorkCenter
This event occurs on loading a work center.
[IntegrationEvent(/*IncludeSender*/false, /*GlobalVarAccess*/false)]
procedure OnBeforeTransferWorkCenter(pClientGuid: Guid;
var pWorkCenterRecord: Record “Work Center”; var pHandled: Boolean)
|
|
Data type |
Description |
|
Parameter: pClientGuid |
Guid |
This value is used for the global identification of VPS Control-AddIn on a page. |
|
var pWorkCenterRecord |
Record |
The work center to be loaded. |
|
var pHandled |
Boolean |
The event will be handled if it returns true |
OnBeforeTransferWorkCenterGroup
This event occurs on loading a work center group.
[IntegrationEvent(/*IncludeSender*/false, /*GlobalVarAccess*/false)]
procedure OnBeforeTransferWorkCenterGroup(pClientGuid: Guid; var pWorkCenterGroupRecord: Record “Work Center Group”; var pHandled: Boolean)
|
|
Data type |
Description |
|
Parameter: pClientGuid |
Guid |
This value is used for the global identification of VPS Control-AddIn on a page. |
|
var pWorkCenterGroupRecord |
Record |
The work center group to be loaded. |
|
var pHandled |
Boolean |
The event will be handled if it returns true |
Comments
0 comments
Please sign in to leave a comment.