diff --git a/Next Status Code - filtered by Product Group/PTEResponsibility.Codeunit.al b/Next Status Code - filtered by Product Group/PTEResponsibility.Codeunit.al new file mode 100644 index 0000000..3b95e80 --- /dev/null +++ b/Next Status Code - filtered by Product Group/PTEResponsibility.Codeunit.al @@ -0,0 +1,25 @@ +codeunit 80278 "PTE Responsibility" +{ + [EventSubscriber(ObjectType::Table, DataBase::"PVS Status Code", 'OnBeforeGetNewStatusFromResponsibilities', '', false, false)] + local procedure OnBeforeGetNewStatusFromResponsibilities(in_ID: Integer; in_CurrStatusCode: Code[20]; in_OrderType: Code[20]; in_CustomerGroup: Code[20]; in_CustomerNo: Code[20]; var out_NewStatusCode: Code[20]; var out_IsHandled: Boolean) + var + CaseRec: Record "PVS Case"; + ResponsibilityRec: Record "PVS Status Responsiblity Area"; + begin + if not CaseRec.get(in_ID) then + exit; + + ResponsibilityRec.Reset(); + ResponsibilityRec.SetFilter(Status, '%1|%2', in_CurrStatusCode, ''); + ResponsibilityRec.SetFilter("Order Type", '%1|%2', in_OrderType, ''); + ResponsibilityRec.SetFilter("Customer Group", '%1|%2', CaseRec."Product Group", ''); + ResponsibilityRec.SetFilter("Sell-To No.", '%1|%2', in_CustomerNo, ''); + ResponsibilityRec.SetFilter("From Date", '..%1', Today()); + ResponsibilityRec.SetFilter("To Date", '%1..|%2', Today(), 0D); + if ResponsibilityRec.FindLast() then + if ResponsibilityRec."Next Status" <> '' then + out_NewStatusCode := ResponsibilityRec."Next Status"; + out_IsHandled := true; + + end; +} diff --git a/Next Status Code - filtered by Product Group/PTEResponsibility.PageExt.al b/Next Status Code - filtered by Product Group/PTEResponsibility.PageExt.al new file mode 100644 index 0000000..5bc8720 --- /dev/null +++ b/Next Status Code - filtered by Product Group/PTEResponsibility.PageExt.al @@ -0,0 +1,19 @@ +pageextension 80278 "PTE Status Responsiblity Area" extends "PVS Status Responsiblity Area" +{ + layout + { + addafter(OrderType) + { + field("Product Group"; Rec."Product Group") + { + ApplicationArea = All; + ToolTip = 'Product Group relates to the "Code" field in table "Product Group".The Product Group can be selected from the Product Group table.If you want a specific status sequence for specific Order type, you select the desired Order type by a look-up in the field. Please note that the selected setup will only apply to the selected order type. Therefore, a set of Responsibility areas must exist for each Order type along with a set without Order type which the system will choose if the order type is different than the one/those defined in Responsibility areas or is not filled in. '; + } + } + modify(CustomerGroup) + { + Visible = false; + Caption = 'Product Group'; + } + } +} diff --git a/Next Status Code - filtered by Product Group/PTEResponsibility.TableExt.al b/Next Status Code - filtered by Product Group/PTEResponsibility.TableExt.al new file mode 100644 index 0000000..142a597 --- /dev/null +++ b/Next Status Code - filtered by Product Group/PTEResponsibility.TableExt.al @@ -0,0 +1,16 @@ +tableextension 80278 "PTE Status Responsiblity Area" extends "PVS Status Responsiblity Area" +{ + fields + { + field(80278; "Product Group"; Code[20]) + { + DataClassification = CustomerContent; + TableRelation = "PVS Product Group"; + Caption = 'Product Group'; + trigger OnValidate() + begin + Rec."Customer Group" := Rec."Product Group"; + end; + } + } +} diff --git a/Next Status Code - filtered by Product Group/README.md b/Next Status Code - filtered by Product Group/README.md new file mode 100644 index 0000000..2ed4e38 --- /dev/null +++ b/Next Status Code - filtered by Product Group/README.md @@ -0,0 +1,54 @@ +# Next Status Code - filtered by Product Group + +This extension customizes how PrintVis finds the next status code from Responsibility Areas. +It introduces Product Group as a setup field and uses it when evaluating which responsibility rule should determine the next status. + +The matching works as follows when the system searches for a next status: + +Status: Matches the current status code or blank. +Order Type: Matches the current order type or blank. +Product Group: Matches the case Product Group or blank. +Sell-To No.: Matches the current Sell-To customer number or blank. +From Date / To Date: Only rules valid on today’s date are considered. +If multiple records match, the last matching record is used. If that record has a value in Next Status, that value is returned as the new status code. + +The Product Group value is maintained on the Responsibility Area setup and is linked to the PVS Product Group table. + +## What this extension includes + +- Codeunit 80278 "PTE Responsibility" +- Tableextension 80278 "PTE Status Responsiblity Area" +- Pageextension 80278 "PTE Status Responsiblity Area" + +## How it works + +The codeunit subscribes to the OnBeforeGetNewStatusFromResponsibilities event on the PVS Status Code table. + +When next status is evaluated: + +It reads the related case. +It filters responsibility lines by Status, Order Type, Product Group, Sell-To No., and date validity. +It picks the last matching line and returns its Next Status (if set). +It marks the event as handled, so this logic controls the result. + +The table extension adds a Product Group field to responsibility setup. +On validation, the extension copies Product Group into Customer Group to preserve compatibility with existing matching behavior. + +The page extension: +adds Product Group to the Responsibility Area page +hides Customer Group from the page + +## Prerequisites to run the functionality + +PrintVis app installed (dependency defined in this extension). +Business Central runtime and application versions compatible with this extension package. + +## What you will need to do for this extension to work +Install the extension package in your environment. +Ensure PrintVis is installed in a compatible version. +Configure Responsibility Area records with: +Status / Order Type as needed +Product Group where product-specific routing is required +Sell-To No. where customer-specific routing is required +valid From Date / To Date ranges +Next Status for each rule you want applied diff --git a/Next Status Code - filtered by Product Group/app.json b/Next Status Code - filtered by Product Group/app.json new file mode 100644 index 0000000..985ec44 --- /dev/null +++ b/Next Status Code - filtered by Product Group/app.json @@ -0,0 +1,39 @@ +{ + "id": "05598f44-6d22-4a63-90bb-1b907daa5644", + "name": "Next Status Code - filtered by Product Group", + "publisher": "PrintVis", + "version": "1.0.0.0", + "brief": "", + "description": "", + "privacyStatement": "", + "EULA": "", + "help": "", + "url": "", + "logo": "", + "dependencies": [ + { + "id": "5452f323-059e-499a-9753-5d2c07eef904", + "name": "PrintVis", + "publisher": "NovaVision Software A/S", + "version": "28.1.2.6" + } + ], + "screenshots": [], + "platform": "1.0.0.0", + "application": "28.0.0.0", + "idRanges": [ + { + "from": 80278, + "to": 80278 + } + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "allowDownloadingSource": true, + "includeSourceInSymbolFile": true + }, + "runtime": "16.0", + "features": [ + "NoImplicitWith" + ] +} \ No newline at end of file