Default consumption values
Shop Floor Production supports setting default values for Register Input fields through integration events. By subscribing to these events, a per-tenant extension (PTE) can define default behavior for the Register Input screen through AL instead of JavaScript.
Fields supported
The following field can have a default value set through an integration event:
- Tare Weight
The Tare Weight field defaults to 0 when no subscriber sets a value. The field is shown only when a weigh scale for consumption is set up for the work center and the component item meets the weigh scale conditions. For more information, see Register input.
Other standard Register Input fields, such as the lot number, expiration date, quantity, bin code, license plate number, and weight quantity, can be pre-populated after a barcode scan through custom consumption scan logic. Those values apply only when the Register Input screen is opened from a custom scan.
Events
The event includes the Production Order Component as a parameter, identifying which component is being registered.
For a default value to be accepted by Shop Floor Production, the
IsHandledparameter must be set totrue.
SFPBCGetFormElements14FDW.Codeunit.al
[IntegrationEvent(false, false)]
local procedure OnBeforeSetDefaultTareWeightForConsumption(ProdOrderComponent: Record "Prod. Order Component"; var TareWeightValue: Decimal; var IsHandled: Boolean)
begin
end;
Example
The following example sets a default Tare Weight of 1.5 for the component item OIL-20L, and leaves the default of 0 for every other component:
[EventSubscriber(ObjectType::Codeunit, Codeunit::SFPBCGetFormElements14FDW, OnBeforeSetDefaultTareWeightForConsumption, '', false, false)]
local procedure SetDefaultConsumptionTareWeight(ProdOrderComponent: Record "Prod. Order Component"; var TareWeightValue: Decimal; var IsHandled: Boolean)
begin
if ProdOrderComponent."Item No." <> 'OIL-20L' then
exit;
TareWeightValue := 1.5;
IsHandled := true;
end;