Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Al Code Help in a Page

(0) ShareShare
ReportReport
Posted on by 151

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;
}
  • aryaps Profile Picture
    aryaps 151 on at
    RE: Al Code Help in a Page

    Hello Nithin & Mohana

    its working now. thank you for your kind Support

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    RE: Al Code Help in a Page

    Please change the below like from

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

    to

    JobPlanningLine."Total Tranfer Qty" += JobPlanningLine."Qty. to Transfer to Journal";

  • aryaps Profile Picture
    aryaps 151 on at
    RE: Al Code Help in a Page

    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

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Al Code Help in a Page

    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
    aryaps 151 on at
    RE: Al Code Help in a Page

    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
  • Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Al Code Help in a Page

    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
    aryaps 151 on at
    RE: Al Code Help in a Page

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

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    RE: Al Code Help in a Page

    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
    aryaps 151 on at
    RE: Al Code Help in a Page

    No its not updating. i checked many jobs

    how we bring it in code,(only posted)

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    RE: Al Code Help in a Page

    I think you didnt transfer anything yet in your screenshot.

    43 is yet to transfer.

    once you transferred then remaining qty should update.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans