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...
Answered

How to assign a value to a field by Event Subscriber on Business Central Extension

(0) ShareShare
ReportReport
Posted on by 25

Hi,

I want to use event subscriber to add fields on Warehouse Pick and assign values to the fields from Sales Order, like sell to information and ship to information.

I'm using flowfield but it uses too much resource to show a page. It takes 15 secs to show the whole page so I want to use a different way to make it.

I can't find a problem of the code. Here is my codeunit. Also, I'd like to know if there's an easy way to do it instead of event subscriber. Thanks!

codeunit 61353 CustomerInfoEvent
{
    [EventSubscriber(ObjectType::PagePage::"Warehouse Pick", 'OnAfterValidateEvent''No.', true, false)]
    local procedure "Warehouse Pick_OnAfterValidateEvent_[content / General] - No."(var Rec: Record "Warehouse Activity Header")
    var
        SalesHeader: Record "Sales Header";
        WarehousePick: Record "Warehouse Activity Header";
    begin
        WarehousePick.get(SalesHeader."Sell-to Customer No.");
        WarehousePick."Sell-To No" := SalesHeader."Sell-to Customer No.";
        WarehousePick."Sell-To Name" := SalesHeader."Sell-to Customer Name";
    end;

    [EventSubscriber(ObjectType::TableDatabase::"Warehouse Activity Header", 'OnAfterInsertEvent''', true, false)]
    local procedure "Warehouse Activity Header_OnAfterInsertEvent"(var Rec: Record "Warehouse Activity Header"; RunTrigger: Boolean)
    var
        SalesHeader: Record "Sales Header";
    begin
        if RunTrigger then
            if Rec."SONo." <> '' then
                if SalesHeader.get(Rec."SONo."then
                    if SalesHeader.get(Rec."Sell-to No"then begin
                        Rec."Sell-To No" := SalesHeader."Sell-to Customer No.";
                        Rec."Sell-To Name" := SalesHeader."Sell-to Customer Name";
                        Rec.Modify();
                    end;
    end;
}
I have the same question (0)
  • Audrey W Profile Picture
    25 on at

    Hi,

    I also tried this. However, it seems only allow to use a field, which format is Enum. If I want to use a field, which is Code[20[, how to modify it? Thank you!

    codeunit 61353 CustomerInfoEvent

    {

       trigger OnRun();

       begin

       end;

       [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Pick", 'OnBeforeWhseActivLineInsert', '', false, false)]

       local procedure CreatePickOnBeforeWhseActivLineInsert(var WarehouseActivityLine: Record "Warehouse Activity Line"; WarehouseActivityHeader: Record "Warehouse Activity Header")

       var

           SalesHeader: Record "Sales Header";

       begin

           if WarehouseActivityHeader.Type = WarehouseActivityHeader.Type::Pick then

               if WarehouseActivityLine."Source Document" = WarehouseActivityLine."Source Document"::"Sales Order" then

                   if SalesHeader.Get(WarehouseActivityLine."Source Subtype", WarehouseActivityLine."Source No.") then begin

                       WarehouseActivityHeader."Sell-To No" := SalesHeader."Sell-to Customer No.";

                       WarehouseActivityHeader.Modify();

                   end;

       end;

  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

  • Verified answer
    Audrey W Profile Picture
    25 on at

    Thank you so much!

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,933 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,055 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 640 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans