web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
New Discussion

How to store and apply values in Copy Item page since version 16.x

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

With Dynamics 365 Business Central 2020 Wawe 1 (16.x), the Copy Item action has been refactored to improve extensibility. 

In previous versions, it was using a Request Page from a report with variables that where stored thanks to the SaveValue property set to true within the request page. In this way, users could reuse the same filters in the next copy item iteration. 

With Dynamics 365 Business Central 2020 Wave 1 (16.x), the Copy Item action now calls page "Copy Item" that is bounded to Copy Item Buffer record and it is temporary. The boolean values are now transformed into bounded fields hence the page cannot save values as it was before. 

This post is just to showcase a  simple mechanism of storing previous filters for a user and have them back when doing the next copy item action through a simple extension. What you need is just one table and one codeunit. 

The table is a copy of the id and fields of Copy Item Buffer table (because of transferfields) boolean values and number or copy. Primary key is set to be User Id

table 50119 "Copy Item Filter Store"
{
    Caption = 'Copy Item Filter Store';

    fields
    {
        field(1; "User ID"; Code[10])
        {
            Caption = 'User ID';
            TableRelation = User."User Name";
            ValidateTableRelation = true;
            DataClassification = SystemMetadata;
        }
        field(5; "Number of Copies"; Integer)
        {
            Caption = 'Number of Copies';
            DataClassification = SystemMetadata;
        }
        field(10; "General Item Information"; Boolean)
        {
            Caption = 'General Item Information';
            DataClassification = SystemMetadata;
        }
        field(11; "Units of Measure"; Boolean)
        {
            Caption = 'Units of Measure';
            DataClassification = SystemMetadata;
        }
        field(12; Dimensions; Boolean)
        {
            Caption = 'Dimensions';
            DataClassification = SystemMetadata;
        }
        field(13; Picture; Boolean)
        {
            Caption = 'Picture';
            DataClassification = SystemMetadata;
        }
        field(14; Comments; Boolean)
        {
            Caption = 'Comments';
            DataClassification = SystemMetadata;
        }
        field(15; "Sales Prices"; Boolean)
        {
            Caption = 'Sales Prices';
            DataClassification = SystemMetadata;
        }
        field(16; "Sales Line Discounts"; Boolean)
        {
            Caption = 'Sales Line Discounts';
            DataClassification = SystemMetadata;
        }
        field(17; "Purchase Prices"; Boolean)
        {
            Caption = 'Purchase Prices';
            DataClassification = SystemMetadata;
        }
        field(18; "Purchase Line Discounts"; Boolean)
        {
            Caption = 'Purchase Line Discounts';
            DataClassification = SystemMetadata;
        }
        field(19; Troubleshooting; Boolean)
        {
            Caption = 'Troubleshooting';
            DataClassification = SystemMetadata;
        }
        field(20; "Resource Skills"; Boolean)
        {
            Caption = 'Resource Skills';
            DataClassification = SystemMetadata;
        }
        field(21; "Item Variants"; Boolean)
        {
            Caption = 'Item Variants';
            DataClassification = SystemMetadata;
        }
        field(22; Translations; Boolean)
        {
            Caption = 'Translations';
            DataClassification = SystemMetadata;
        }
        field(23; "Extended Texts"; Boolean)
        {
            Caption = 'Extended Texts';
            DataClassification = SystemMetadata;
        }
        field(24; "BOM Components"; Boolean)
        {
            Caption = 'BOM Components';
            DataClassification = SystemMetadata;
        }
        field(25; "Item Vendors"; Boolean)
        {
            Caption = 'Item Vendors';
            DataClassification = SystemMetadata;
        }
        field(26; Attributes; Boolean)
        {
            Caption = 'Attributes';
            DataClassification = SystemMetadata;
        }
        field(27; "Item Cross References"; Boolean)
        {
            Caption = 'Item Cross References';
            DataClassification = SystemMetadata;
        }
    }

    keys
    {
        key(Key1; "User ID")
        {
            Clustered = true;
        }
    }

}


The last piece of the puzzle is a codeunit that subscribe 2 events: the first one is fired when initializing the page (to re-apply existing boolean choices already stored) and the second one right after user input and before closing the page (to gather changes in the selection).
codeunit 50109 "Copy Item Filter Management"
{
    [EventSubscriber(ObjectType::PagePage::"Copy Item", 'OnAfterInitCopyItemBuffer''', true, true)]
    local procedure OnAfterInitCopyItemBuffer(var CopyItemBuffer: Record "Copy Item Buffer")
    begin
        IF CopyItemFilterStore.GET(UserIdthen begin
          CopyItemBuffer.TransferFields(CopyItemFilterStore,false);
          CopyItemBuffer.Modify();
        end;
    end;

    [EventSubscriber(ObjectType::PagePage::"Copy Item", 'OnAfterValidateUserInput''', true, true)]
    local procedure OnAfterValidateUserInput(var CopyItemBuffer: Record "Copy Item Buffer")
    begin
        IF CopyItemFilterStore.GET(UserIdthen begin
          CopyItemFilterStore.TransferFields(CopyItemBuffer,false);
          CopyItemFilterStore.Modify();
        end else begin
          CopyItemFilterStore.Init();
          CopyItemFilterStore."User ID" := UserId;
          CopyItemFilterStore.TransferFields(CopyItemBuffer,false);
          CopyItemFilterStore.Insert();  
        end;
    end;

    var
        CopyItemFilterStore : Record "Copy Item Filter Store";
}
In this way, whenever a user is applying any changes to the way filter are selected, these are stored and reapplied in the next iteration like it was with Dynamics 365 Business Central 2019 Wawe 2 (15.x) and earlier

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,926 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,158 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 533 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans