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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Assign a value from Gen Business Posting Group Table.

(0) ShareShare
ReportReport
Posted on by 358

I have got Gen Bus. Posting Group field showing on the subform of Sales Order. This Subform is also showing Location Code for the Line.



I am attempting to write a logic as such that if the User selects Location Code as DROPSHIP, the Gen Bus. Posting Group should be LOCAL-DROPSHIP.



LOCAL-DROPSHIP is a record in the Gen. Bus. Posting Group. I have created it before writing this code. However, it would not assign to my rec.Gen Bus. Posting Group.



Here is the code on the Subform;

modify("Location Code")
        {
            trigger OnAfterValidate()
            var
                recLocation: Record Location;
                recCustomer: Record Customer;
                recSalesLine: Record "Sales Line";
                recGenPosting: Record "Gen. Business Posting Group";

            begin
                recGenPosting.Get('LOCAL-DS');
                if rec."Location Code" = 'DROPSHIP' then begin
                    Message(recGenPosting.Code);
                   // Validate("Gen. Bus. Posting Group", recGenPosting.Code);
                    Rec."Gen. Bus. Posting Group" := recGenPosting.Code;
                    CurrPage.Update();
                end;
            end;
        }

I have the same question (0)
  • Suggested answer
    ArturV Profile Picture
    225 on at

    You call CurrPage.Update without parameter and this would not save your record. So you need to either:

    Rec."Gen. Bus Posting Group" := recGenPosting.Code;

    Rec.Modify;

    CurrPage.Update;

    OR

    Rec."Gen. Bus Posting Group" := recGenPosting.Code;

    CurrPage.SAVERECORD;

    However, i won't write this code on the page but rather in table. It will help you to avoid unnecessary Rec.Modify call since it will be called anyway after Validate trigger run.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans