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

Notifications

Announcements

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 980

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)
  • Indira88 Profile Picture
    980 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

  • Suggested answer
    JAngle Profile Picture
    137 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

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

News and Announcements

Season of Giving Solutions is Here!

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 1,513

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 742 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 706 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans