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

add additional parameter to an existing method

(0) ShareShare
ReportReport
Posted on by 678

Hi All,

I would like to add a new parameter to the existing class method (see below example). It seems that it is impossible to achieve via class extension. 

    public boolean  checkItemDraw(
        InventQty       _inventQty,
        NoYes           _negativePhysical,
        boolean         _addInfo = true,
        PdsCWInventQty  _cwQty = 0
        // additional parameter here //
        )
    {

What would be the best way to achieve it? 

Thank you. 

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    I assume this question is about D365FO, therefore let me move it to the right forum.

    You're right, you can't add a parameter through extensions. You'll have to design another approach to implementing your requirement. Unfortunately we know nothing about your business requirement, therefore we can't comment on it at the moment.

  • WillWU Profile Picture
    22,361 on at

    Hi ShawnDEV,

    As Martin mentioned, you can't add parameters via extensions, you can log a request of extension to Microsoft:

    docs.microsoft.com/.../extensibility-requests

  • Suggested answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    If the structure allows it, define a global variable to class. You can filling it with a parm method and using it in the checkItemDraw method.

  • ShawnDEV Profile Picture
    678 on at

    Hi,

    I have checked that this method is called from InventUpd_Picked.updatePickInventTrans (protected) method 

    I want to add extra parameter _inventTrans.InventTransOrigin().inventTransId as follows 

    if (!inventOnHandQty.checkItemDraw(_inventTrans.Qty,
                                                   allowNegativePhysical,
                                                   true,
                                                   _inventTrans.PdsCWQty))
                                                   //(add) _inventTrans.InventTransOrigin().inventTransId

    How can we achieve it? 

    Thank you

  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    Again - you can't. You must leave the idea of adding parameters and think about a different solution.

    If you need our help, tell us what you're trying to achieve from the business point of view.

  • Suggested answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    If I m not wrong you have inventMovement. I think the inventMovement have InventTransId

  • ShawnDEV Profile Picture
    678 on at

    Hi,

    yes it is right that InventTransId can be found from inventMovement class instance.

    But I wonder how to get the instance of it in the InventOnhandQty class. The InventOnhandQty  class method checkItemDraw is called from InventUpd_Picked class.. but I am having difficulty to get the variable from InventUpd_Picked  to the InventOnhandQty  class.

    Thank you.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    I didn't go the details of these classes.

    But you can add simple parm method to InventOnHandQty and use it to set/get class variables of InventOnHandQty.

    Here's an illustration: you can add new "MyNewMethodForPassingAnyInfo" method to InventOnHandQty via class augmentation ([ExtensionOf...).

    Then you can call it from InventUpd_Picked.updatePickInventTrans method and pass whatever info you like:

            if (checkOnhand)
            {
                InventOnHandQty inventOnHandQty = InventOnHandQty::newPhysicalUpdate(movement, pickInventDimCriteria);
    
                inventOnHandQty.MyNewMethodForPassingAnyInfo("Any info");
                
                if (!inventOnHandQty.checkItemDraw(_inventTrans.Qty,
                                                   allowNegativePhysical,
                                                   true,
                                                   _inventTrans.PdsCWQty))
                {
                    throw error("@SYS18447");
                }
            }

    Is it now clear?

    However InventOnHandQty::newPhysicalUpdate method already takes an InventMovement object, which contains quite a lot of information. Perhaps you don't need to pass any additional info. 

  • ShawnDEV Profile Picture
    678 on at

    Hi,

    This is D365 and how can we add line 5 to the InventUpd_Picked.updatePickInventTrans method directly? This is application suite class.

    Thank you.

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    [deleted]

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 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans