Skip to main content

Notifications

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

Expose GST Line Amount of Sales Invoice Line to a Custom API

(1) ShareShare
ReportReport
Posted on by 13
Hi Experts,
 
I tried to create a custom API that expose Sales Invoice Header and Sales Invoice Line in a single API call.
I'm not using the standard API as I'd want to include my custom fields.
However, I noticed that there're no easy way to expose the GST line amount in Sales Invoice Line (where GST line amount = Line Price including GST - Line Price excluding GST).
Any suggestions?
Thanks.
 
Regards,
Kevin
Categories:
  • Suggested answer
    Yi Yong Profile Picture
    Yi Yong 1,391 Super User 2024 Season 2 on at
    Expose GST Line Amount of Sales Invoice Line to a Custom API
    Hello,
     
    You can create a var decimal and calculate the GST using onaftergetrecord function.
     
        layout
        {
            area(content)
            {
                repeater(Group)
                {
                    field(DocNo; Rec."Document No.") { }
                    field(LineNo; Rec."Line No.") { }
                    field(GSTAmt; GSTAmt) { }
                }
            }
        }
    
        var
            GSTAmt: Decimal;
    
        trigger OnAfterGetRecord()
        begin
            Clear(GSTAmt);
            GSTAmt := Rec."Amount Including VAT" - Rec."Line Amount";
        end;
     
    ​​​​​​​

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

Announcing Category Subscriptions!

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,253 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans