Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

EXTENSTION GET UNIT PRICE FROM RESOURCE TABLE AND ASSIGN TO VARIABLE TO CALCULATE TOTAL PRICE

Posted on by

Hi All 

I am new to AL programming and requires some help in the follwing query , i need to get the unti price from Resouce table and assinge to Varibable for Further calculation and dispalyin on the Assembly line sub form.

its erroring in the part 

                SELECT "Unit_Price"
                FROM "Resource"
                WHERE "Resource ID" = varResourceID
                INTO varUnitPrice;
Here is the full code 
pageextension 50003 PageExtension50003 extends "Assembly Order Subform"
{
    layout
    {
        addafter("Unit Cost")
        {
            field("ZY Resource Unit Price"; Rec.ZY_ResourceUnitPrice)
            {
                ApplicationArea = All;
               
            }
            field("ZY Resource Margin92783"; Rec.ZY_ResourceMargin)
            {
                ApplicationArea = All;
            }
            field("ZY Total Price"; Rec.ZY_TotalPrice)
            {
                ApplicationArea = All;
            }
        }
    }

    var
        varResourceID : Code[20] ;
        varUnitPrice: Decimal;
        varQuantity : Decimal;
        UpriceTot : Decimal;

    trigger OnNewRecord(BelowxRec: Boolean)
    begin
        varResourceID := Rec."No.";
        varUnitPrice := 0;
        varQuantity := Rec.Quantity;
        UpriceTot := 0;
 
   
                SELECT "Unit_Price"
                FROM "Resource"
                WHERE "Resource ID" = varResourceID
                INTO varUnitPrice;

        UpriceTot := varUnitPrice * varQuantity;
        Rec.ZY_ResourceUnitPrice := varUnitPrice;
        Rec.ZY_TotalPrice := UpriceTot;
    end;
 
 


}

Appriciate your experties and time and Tahks in Advanced. 

Categories:
  • Suggested answer
    Marco Mels Profile Picture
    Marco Mels on at
    RE: EXTENSTION GET UNIT PRICE FROM RESOURCE TABLE AND ASSIGN TO VARIABLE TO CALCULATE TOTAL PRICE

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    www.dynamicsuser.net/.../14

    I will open this up to the community in case they have something to add.

    Thanks.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,030 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans