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 :
Microsoft Dynamics NAV (Archived)

How to add optional parameter to a function

(0) ShareShare
ReportReport
Posted on by 453

Hi 

I have a function in Business Central. And I want to add an optional parameter to it. 

procedure PostSalesOrder(var SalesOrder: Record "Sales Header"): Boolean


*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    There are no optional parameters in C/SIDE and AL. If your function has two parameters, you need to pass two values. In your code you can test if they are empty or not.

  • Community Member Profile Picture
    on at

    I think you dont want to touch this function. My suggest create a new function with this paramater / parameters.

  • Suggested answer
    Yuri Mishin Profile Picture
    20 on at

    You can overload functions. Define a new function with the same name an additional parameters, something like this:

    procedure PostSalesOrder(var SalesOrder: Record "Sales Header"; OptionalParam: Integer) Result: Boolean

    begin

       // Preprocess your OptionalParam here (i.e. store it in a global variable in order to access it in original function)

       Result := PostSalesOrder(SalesOrder);

       // Postprocess your OptionalParam here

    end;

  • ManishS Profile Picture
    86 on at

    What is the functioning of that additional parameter.

  • SU-07061748-0 Profile Picture
    13 on at
    Simple.
     
     
    You can overload the function with different parameters.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans