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

Putting Interlocks if Job No. or Job Task No. are blank in Purchase lines of a purchase order

(0) ShareShare
ReportReport
Posted on by 990

Hi All,

I have a problem where I have to check whether the Purchase Line records have job no. or Job Task no. in the subform when I open a purchase order.

If any one row has a blank job no. field or a blank job task no. field I will have to Error message on click of release

I am using the following code:

 modify(Release)
        {
            trigger OnBeforeAction()
            begin
                BeforeRelease();

            end;

        }


    }
    procedure BeforeRelease()
    var

        PurchaseLine: Record "Purchase Line";
        PurchHeader: Record "Purchase Header";

        OldDescription: Text;
    begin
        PurchaseLine.SetRange("Document Type", PurchHeader."Document Type");
        PurchaseLine.SetRange("Document No.", PurchHeader."No.");


        if PurchaseLine.FindSet then begin
            repeat
                PurchaseLine.Init();
                PurchaseLine.Copy(PurchaseLine);
                if PurchaseLine."Job No." = OldDescription then begin
                    Error('hhhh');
                end;

            until PurchaseLine.Next = 0;
        end;
    end;

The above code is not fetching any value of the Purchase lines .not sure why.

Please help.Attached is a screenshot

pastedimage1611096307095v1.png

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    150 on at

    Not sure why you need the copy if you’re not using the Rec. The action doesn’t pass any context of the current record. I’d make sure the Rec which will be the header is equal to your purchase header variable first.

    I believe this would better if you used the codeunit event subscriber for releasing instead. That way you get the context. Plus you could build up a text variable for an error that handles more lines. Line by line errors can be a lame UX

  • Indira88 Profile Picture
    990 on at

    Hi JAngle,

    Thank you for the help. The creating of a codeunit and triggering the event subscription helped in checking for each row of dataset.

    Regards,

    Indira

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,821 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,122 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans