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

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 464 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans