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

Al Code Help in a Page

(0) ShareShare
ReportReport
Posted on by 155

Dear all,

i am stuck with the al code for doing this issue.

. In the Job planning Lines Page, there are Columns called Qty and Qty to Transfer to Journal. we need to add one column after Qty to Transfer Journal with the total of items already transferred to the journal based on the Qty Column (if the type is Item) and Posted that Jorurnal

Here in the screen shot, the 1st line Total Qty is 100 and we transferred 43 so in total Qty Column Transferred also should come 43. if we transfer the again 10 from the total of 100 Qty then total transfer Column should update 43+10 = 53

once fully transferred then it should be same as Qty column.

JobQty.jpg

pageextension 60201 "Total Qty-Job Planning Lines" extends "Job Planning Lines"
{
    layout
    {
        // Add changes to page layout here
        addafter("Qty. to Transfer to Journal")
        {
            field("Total Tranfer Qty";Rec."Total Tranfer Qty")
            {
                ApplicationArea = all;
                Caption = 'Total Transferred Qty';
                Editable= false;
            }

        }
    }
   
    trigger OnAfterGetRecord()

    var

    QtyTotal : Record "Job Planning Line";

    begin
            QtyTotal.Reset();
            QtyTotal.SetRange("Type", QtyTotal."Type"::Item);

    end;
}
I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    60,997 Super User 2025 Season 2 on at

    There is a remaining quantity field.

    You can also calculate Total Tranfer Qty := Quantity - Remaining Quantity;

  • aryaps Profile Picture
    155 on at

    Thank you for the reply

    but the remaining qty column is already i checked. it was not working as expected.

    in screenshot, we can see that total qty is 100 and already transferred is only 43 then also remaining is showing 0

    we need total of qty all already transferred till now? 

    for eg: total is 100 in 1st line. now we transfer 43, next time 10 then total should increase to 53

    remqty.jpg

  • Suggested answer
    Mohana Yadav Profile Picture
    60,997 Super User 2025 Season 2 on at

    I think you didnt transfer anything yet in your screenshot.

    43 is yet to transfer.

    once you transferred then remaining qty should update.

  • aryaps Profile Picture
    155 on at

    No its not updating. i checked many jobs

    how we bring it in code,(only posted)

  • Suggested answer
    Mohana Yadav Profile Picture
    60,997 Super User 2025 Season 2 on at

    Ohh ok.

    The you have to use OnFromPlanningLineToJnlLineOnBeforeCopyItemTracking event to update JobPlanningLine field Total Tranfer Qty

    JobPlanningLine .Total Tranfer Qty += JobPlanningLine .Quantity;

    JobPlanningLine .modify;

  • aryaps Profile Picture
    155 on at

    How we can write in al code. anyone pls help me on this

  • Nitin Verma Profile Picture
    21,698 Moderator on at

    You can do as per the following in the codeunit.

       [EventSubscriber(ObjectType::Codeunit, Codeunit::"Job Transfer Line", 'OnFromPlanningLineToJnlLineOnBeforeCopyItemTracking', '', false, false)]

       local procedure OnFromPlanningLineToJnlLineOnBeforeCopyItemTracking(var JobJournalLine: Record "Job Journal Line"; var JobPlanningLine: Record "Job Planning Line"; var IsHandled: Boolean);

       begin

           JobPlanningLine."Total Tranfer Qty" += JobJournalLine.Quantity;

           JobPlanningLine.Modify();

       end;

  • aryaps Profile Picture
    155 on at

    Thankyou Nithin for your kind Support. Most of the times you are helping me alot to crack the result.

    here the field not coming .but while compiling no error is come. 

    tableextension 60102 "Total Qty-Job Planning Lines" extends "Job Planning Line"
    {
        fields
        {
            // Added a New field for the Sum of Total Tranfered Qty to Journal on Job Planning lines

            Field(60102; "Total Tranfer Qty"; integer)
            {
                Caption = 'Total Transferred Qty';
            }

        }

    }


    Codeunit 60351 "Transfer Qty_Job Planning Line"
    {
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Job Transfer Line", 'OnFromPlanningLineToJnlLineOnBeforeCopyItemTracking', '', false, false)]

        local procedure OnFromPlanningLineToJnlLineOnBeforeCopyItemTracking(var JobJournalLine: Record "Job Journal Line"; var JobPlanningLine: Record "Job Planning Line"; var IsHandled: Boolean);

        begin

            JobPlanningLine."Total Tranfer Qty" += JobJournalLine.Quantity;

            JobPlanningLine.Modify();

        end;
    }
    planingline.jpg
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at

    Make this field as Decimal

    Field(60102; "Total Tranfer Qty"; Decimal)

    Did you try to post Job Journal? If it will be updated if you post the Job journal.

    Thanks.

  • aryaps Profile Picture
    155 on at

    Yes i changed to decimal and post the Journal then also its not coming.

    just now i entered the item, then post the item also. then also the field doesnt have an value

    p22.jpg

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 2,990

#2
Jainam M. Kothari Profile Picture

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

#3
YUN ZHU Profile Picture

YUN ZHU 1,028 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans