Info | ||
---|---|---|
| ||
|
...
Define a new field to hold data
tableextension50101"MOB Case PackageSetupExt"extends"MOB Mobile WMS Package Setup"
{
fields
{
field(50100; "MOB Register Temperature"; Boolean)
{
Caption = 'Register Temperature';
DataClassification = CustomerContent;
}
field(50101; "MOB Default Temperature"; Decimal)
{
Caption = 'Default Temperature';
DataClassification = CustomerContent;
DecimalPlaces = 0 : 5;
MinValue = 0;
}
}
}
pageextension50101"MOB Case PackageSetupExt"extends"MOB Mobile WMS Package Setup"
{
layout
{
addafter(RegisterHeight)
{
field("RegisterTemperature"; Rec."MOB Register Temperature")
{
ApplicationArea = All;
ToolTip = 'Specifies if the Temperature should be registered';
}
field("DefaultTemperature"; Rec."MOB Default Temperature")
{
ApplicationArea = All;
ToolTip = 'Specifies the default Temperature';
}
}
}
}
Define new fields to setup if Temperature should be registered and specify an optional default value
tableextension50100"MOB Case LicensePlateExt"extends"MOB License Plate"
{
fields
{
field(50100; "MOB Temperature"; Decimal)
{
Caption = 'Temperature';
DataClassification = CustomerContent;
DecimalPlaces = 0 : 5;
MinValue = 0;
}
}
}
pageextension50100"MOB Case LicensePlateExt"extends"MOB License Plate"
{
layout
{
addafter(Height)
{
field("Temperature"; Rec."MOB Temperature")
{
ApplicationArea = All;
ToolTip = 'Specifies the Temperature';
}
}
}
}
...
/// <summary>
/// Add a new Step for your own Custom Field 'Temperature'
/// </summary>
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistration_OnAddSteps', '', true, true)]
localprocedure OnPostAdhocRegistration_OnAddSteps(_RegistrationType: Text; var _RequestValues: Record"MOB NS Request Element"; var _Steps: Record"MOB Steps Element"; var _RegistrationTypeTracking: Text)
begin
ifnot (_RegistrationType in ['PackagesToShipLookup', 'BulkRegPackageInfo']) then
exit;
// Break if our step is already collected to prevent infinite loop
if _RequestValues.HasValue('Temperature') then
exit;
AddMyExtraSteps(_Steps, _RequestValues);
end;
/// <summary>
/// Helper Function to insert Custom Step 'Temperature' based on Package Setup table
/// </summary>
localprocedure AddMyExtraSteps(var _Steps: Record"MOB Steps Element"; var _RequestValues: Record"MOB NS Request Element")
var
PackageSetup: Record"MOB Mobile WMS Package Setup";
LicensePlate: Record"MOB License Plate";
begin
GetPackageSetup(LicensePlate, PackageSetup, _RequestValues);
if PackageSetup."MOB Register Temperature"thenbegin
_Steps.Create_DecimalStep(100000, 'Temperature');
_Steps.Set_header('Temperature');
_Steps.Set_helpLabel('Enter Temperature:');
if LicensePlate.Temperature <> 0then
_Steps.Set_defaultValue(LicensePlate.Temperature)
else
_Steps.Set_defaultValue(PackageSetup."MOB Default Temperature");
_Steps.Save();
end;
end;
/// <summary>
/// Helper Function to Identify and return License Plate and Package Setup based on RequestValues as input
/// </summary>
localprocedure GetPackageSetup(var _LicensePlate: Record"MOB License Plate"; var _PackageSetup: record"MOB Mobile WMS Package Setup"; var _RequestValues: Record"MOB NS Request Element")
var
PackageType: Record"MOB Package Type";
WhseShipmentHeader: Record"Warehouse Shipment Header";
PackageTypeCode: Code[100];
LicensePlateNo: Code[20];
BackendID: Text;
begin
Evaluate(BackendID, _RequestValues.GetValue('BackendID'));
Evaluate(PackageTypeCode, _RequestValues.GetValue('PackageType'));
Evaluate(LicensePlateNo, _RequestValues.GetValue('LicensePlate'));
// Try to get the 'Shipping Agent'
ifnot WhseShipmentHeader.Get(BackendID) or (WhseShipmentHeader."Shipping Agent Code" = '') then
exit;
// Try to get the 'Package Type'
ifnot PackageType.Get(PackageTypeCode) then
exit;
// Try to find the specific setup for the combination of 'Shipping Agent' and 'Package Type'
ifnot _PackageSetup.Get(WhseShipmentHeader."Shipping Agent Code", PackageType.Code) then
exit;
// Try to get the License Plate
ifnot _LicensePlate.Get(LicensePlateNo) then
exit;
end;
Handle the collected value from the steps and store data.
...
/// <summary>
/// Transfer collected value from Custom Step 'Temperature' to a custom Field 'Temperature' on the License Plate
/// </summary>
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Pack Adhoc Reg", 'OnPostAdhocRegistrationOnPackagesToShip_OnAfterUpdateLicensePlate', '', false, false)] //
localprocedure OnPostAdhocRegistrationOnPackagesToShip_OnAfterUpdateLicensePlate(var _LicensePlate: Record"MOB License Plate"; var _RequestValues: Record"MOB NS Request Element")
var
TemperatureValue: Decimal;
begin
TemperatureValue := _RequestValues.GetValueAsDecimal('Temperature');
if TemperatureValue <> 0thenbegin
_LicensePlate.Validate(Temperature, TemperatureValue);
_LicensePlate.Modify()
end;
end;
/// <summary>
/// Transfer collected value from Custom Step used in Bulk Registration to Field on License Plate
/// </summary>
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Pack Adhoc Reg", 'OnPostAdhocRegistrationOnBulkRegPackageInfo_OnAfterUpdateLicensePlate', '', false, false)] //
localprocedure OnPostAdhocRegistrationOnBulkRegPackageInfo_OnAfterUpdateLicensePlate(var _LicensePlate: Record"MOB License Plate"; var _RequestValues: Record"MOB NS Request Element")
var
TemperatureValue: Decimal;
begin
TemperatureValue := _RequestValues.GetValueAsDecimal('Temperature');
if TemperatureValue <> 0thenbegin
_LicensePlate.Validate("MOB Temperature", TemperatureValue);
_LicensePlate.Modify()
end;
end;
Check if Temperature has been registered and determine if the License Plate can be marked as "ready" (green checkmark)
...
/// <summary>
/// Check if your custom Field 'Temperature" is required in the current Package Setup and set the value of the "PackageInfoColled" flag (determine if a Green Checkmark is shown)
/// </summary>
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB License Plate Mgt", 'OnCheckLicensePlatePackageInfo', '', false, false)]
localprocedure OnCheckLicensePlatePackageInfo(_LicensePlate: Record"MOB License Plate"; _PackageSetup: Record"MOB Mobile WMS Package Setup"; var _IsPackageInfoCollected: Boolean)
begin
// Default value for _IsPackingInfoCollected is true
if _IsPackageInfoCollected = false then
exit;
if _PackageSetup."MOB Register Temperature"and (_LicensePlate.Temperature = 0) then
_IsPackageInfoCollected := false
end;
Determine if the new Field Temperature should be Cleared, based on changed Package Setup if either the Shipping Agent or Package Type are changed.
...
/// <summary>
/// Handle cleanup for your own Custom Field 'Temperature' on License Plate when Package Setup changes.
/// Package Setup will change when an other Shipping Agent or Package Type is selected
/// </summary>
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Pack Adhoc Reg", 'OnPostAdhocRegistrationOnPackagesToShip_OnUpdateLicensePlateFromPackageSetup', '', false, false)]
localprocedure OnPostAdhocRegistrationOnPackagesToShip_OnAfterUpdateLicensePlateFromPackageSetup(var _LicensePlate: Record"MOB License Plate"; _PackageSetup: Record"MOB Mobile WMS Package Setup")
begin
if _PackageSetup."Package Type" = ''then // No PackageSetup available
Clear(_LicensePlate.Temperature);
ifnot _PackageSetup."MOB Register Temperature"then
Clear(_LicensePlate.Temperature);
end;
Test your solution
Start by manually updating the new fields in the Package Setup Page for any package type in Business Central.
Select the Pack & Ship menu on the mobile device and select Warehouse Shipment to Pack.
...