Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

How to pass checkbox value from form method to class method

Posted on by Microsoft Employee

hi all,

I have passed a checkbox value in form -button clicked method as below: 

classname::getMethod(UnapprovedReq.checked(true)));

UnapprovedReq is my checkbox name in form design.

In class method, I have declared as

public static getMethod(Noyes _noYes)

i'm getting error as "Parameter _noYes must have a default value"

anybody please help me how can I retrieve the checkbox value on class which is passed from Form Button click method.

*This post is locked for comments

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: How to pass checkbox value from form method to class method

    What exactly did you try ? Probably it's a good idea to share your code because it's hard to understand what is wrong without it.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pass checkbox value from form method to class method

    Hi,

    The class method to which I'm passing the value from form, has many other parameters like datevalue, containers and my checkbox value. So Public static has been used. And Class.run() is called in this method only.

    hence I'm not able to call run() from the form.

    so I wanted to know how to retrieve this checkbox value in class method.

    I tried with Boolean but it didn't work.

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: How to pass checkbox value from form method to class method

    Hi Lakshmi.ch,

    I have not seen this error before, can you explain what exactly are you doing ?

    I'm not quite sure why do you have static method. I think you need to declare a variable in classDeclaration method of your class:

    public class MyClass
    {
        boolean isChecked;
    }

    Then you need to create parm method

    public boolean parmIsChecked(boolean _isChecked = isChecked)
    {
        isChecked = _isChecked;
        return isChecked;
    }

    and then in a button click instantiate new intance of the class and pass value of checkbox to the parm method:

    void clicked()
    {
        MyClass myClass = new MyClass();  //instantiate
    
        super();
    
        myClass.parmIsChecked(UnapprovedReq.checked()); //pass value
    myClass.run() //do something }

    You don't need to pass "true" to UnapprovedReq.checked() because it will set a value of checkbox.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,219 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans