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...
Suggested Answer

comparing same fields in multiple rows

(0) ShareShare
ReportReport
Posted on by 1,037

Added a new field called customer P.O in the job Planning lines table

pastedimage1609282567622v1.png

I have to compare the rows and make sure the customer po number value is the same or else will not let the job planning lines to transfer how could this be achieved?

how can I compare the rows and the fields.

Regards,

Indira

  • Suggested answer
    Community Member Profile Picture
    on at

    Indira,

    Since this is a custom field added to the Job Planning Lines via an extension, I see 2 options:

    1. Using the Customer PO No. field, add a filter <>PO value. Here you see those lines NOT EQUAL to the value you need

    2. Create a Validation Check utility, within your extension, that adds an Action button to validate the Job Planning Lines Purchase Order No. are all the same. Pop a message when a Planning Line is not.

    The filter is the easier solution. You mention 'will not let the job planning lines to transfer...'. I am thinking you are talking about creating Job Journal lines or Invoices. If you are trying to prevent this action from processing, when the Purchase Order No. is not the same, then I would add the #2 validation to the action to check before executing.

    I hope I followed your question and provided some guidance.

    Thanks,

    Steve

    Don't forget to help the community by verifying the answer if your question has been answered. It will let others know that the topic has verified answer.

  • Indira88 Profile Picture
    1,037 on at

    Hi Steve,

    Thanks for the update.I am planning to write a routine subscribing to an event while it will try to create invoice from job planning lines.How is the code written i want to know.

    How is the comparison done in Al?

    How is the field valye checked for each row.

    I hope I can make you understand the problem

  • Suggested answer
    Bilal Haider Profile Picture
    487 on at

    Hi,

    You have not told from where other Customer PO Value is coming while one is in Job Planning Line. Suppose you have other PO value in CustomerPOValue then you can compare like this.

    //Apply filters on Job Planning line if you need to filter for specific Job or Job task etc.

    JobPlanningLines.SetRange(Field,'Value);

    If JobPlanningLines.FINDSET then

    Repeat

    If JobPlanningLine."Customer PO No" = CustomerPOValue then begin

       //You logic to transfer

    end

    Until JobPlanningLines.Next = 0;

  • Indira88 Profile Picture
    1,037 on at

    Hi Bilal,

    Thank you .The customer P.O field lies in the job Planning Line table .I have to put an error message if the field values are not same for each row.

    the customer po value entered should be same for each job task.

    the following is what I have written:

     JobPlanningLine.Copy(JobPlanningLine);
            JobPlanningLine.SetFilter("WCI Description 2", JobPlanningLine."WCI Description 2");
            if JobPlanningLine.FindSet() then
                repeat
                    If JobPlanningLine."WCI Description 2" <> JobPlanningLine."WCI Description 2" then begin
                        Error(Text002);
                    end

                until JobPlanningLine.Next() = 0;
  • Indira88 Profile Picture
    1,037 on at

    Issue is resolved by using TestField.Thank you Steve and Bilal.

     JobPlanningLine.Copy(JobPlanningLine);

           customerPO := JobPlanningLine."WCI Description 2";

           if JobPlanningLine.FindSet() then

               repeat

                   JobPlanningLine.TestField("WCI Description 2");

                   If JobPlanningLine."WCI Description 2" <> customerPO then begin

                       Error(Text002);

                   end

               until JobPlanningLine.Next() = 0;

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 677 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 430 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 280 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans