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 "ResExtension" extends Resource
{
fields
{
//Examples how to calculate BC data
// Count("Resource" 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("Res. Capacity Entry".Capacity WHERE(
"Resource No." = FIELD("No."),
Date = FIELD("Date Filter")));
Caption = 'Capacity (CustomDefinition)';
DecimalPlaces = 0 : 5;
Editable = false;
FieldClass = FlowField;
}
}
}
The SIM tables enhancements done by the partner
tableextension 60003 "ResSIMExtension" extends "NETVJS SIMResource"
{
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
[EventSubscriber(ObjectType::Codeunit, Codeunit::"NETVJS IntegrationMgmt",
'OnBeforeTransferResource', '', false, false)]
local procedure handleOnBeforeTransferResource(pClientGuid: Guid; var
pResourceRecord: Record Resource; var pHandled: Boolean)
var
adate: Date;
begin
if gEventHandlingActivate then begin
adate := WorkDate();
pResourceRecord."Date Filter" := adate;
pResourceRecord.SetRange("Date Filter", adate);
if pResourceRecord.CalcFields("Capacity (CustomDefinition)") then;
pHandled := true;
end;
end;
These data can be displayed in tooltip, bar, or table:
Find information about the events in detail here.
Comments
0 comments
Please sign in to leave a comment.