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 :
Finance | Project Operations, Human Resources, ...
Answered

How to add optional parameter in method?

(0) ShareShare
ReportReport
Posted on by 932

Hi,

MyMethod(RecId recId,Set _updateElementChecked = new Set(Types::Int64),
Set _browsFormChecked = new Set(Types::String))

I want to make the 2 "Set" parameters as optional  => I means when I call this method I can write this:

MyMethod(RecId recId);

I have the same question (0)
  • Suggested answer
    Adria Ariste Profile Picture
    User Group Leader on at

    Hi,

    in X there's no optional parameters, or at least they're not called optional but default value. You can do it like this:

    MyMethod(RecId recId, Set _updateElementChecked = null, Set _browsFormChecked = null)

    This will allow you to call the method like MyMethod(recId).

    Adrià Ariste - Senior technical consultant @ Axazure - Read my blog!

  • Verified answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    In your code the Set parameters are already optional, since you provide default values for them.

  • Verified answer
    Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Basma,

    As Nikolaos said, the parameters in your method are already optional.

    Initialize the parameters in the method declaration. This will make the parameter an optional parameter.
    If no value is provided in the method call, the default value is used.

    Simple test, you will find that the method can be called normally.

    5582.PNG

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans