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 :
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,166 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

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

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans