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

Unmark the checkbox based on custom button click

(0) ShareShare
ReportReport
Posted on by 45

Hi Team ,

I have added existing form (Sales order details) to the current project . And in the form design added two controls..one is check box  and other one button in Line Overview Action Pane .Here i am confusing in COC and event handler, which one is a good approach to achieve the action .

Action: When i click the button then the checkbox will be unmarked to related sales lines details .Kindly suggest me the solution for this.

Thanks,

Prasad N.

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi prasadn.nampalli,

    Its upto you. You can write either event handler or COC. Also tell me whether check box is DataSource bound control or not?

    You can go for COC because you can get the control name by simply setting the "Auto declaration" property to yes and you can use it in clicked method of the button control.

    [Extensionof(formcontrolstr(FormName,controlname))]
    final class className_Extension
    {
        public void clicked()
        {
            next clicked();
            YourCheckBoxControlName.value(false);
        }
    }

    Thanks,

    Girish S.

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at

    Hi Girish,

    Thanks for your suggestion..

    I tried with the COC but here checkbox is of type Noyes enumarator type .

    getting error while declaring the sentence .Please suggest me

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at

    Yes, Check box is bound to data source ..added new field at table level .

  • GirishS Profile Picture
    27,827 Moderator on at

    If control is bound to DataSource, then you need to update all the line records because there may be one or more lines.

    Can you show as a screenshot of the form UI with new controls added in it?

    Thanks,

    Girish S.

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Hi Prasad,

    Can you please send the error here?

    Also if it is a NoYes control then you might have added that to the datasource and then to form. So basically you need to update that with coding. You can take onclicked eventhandler/onclicked method in which you need to take that table buffer and update that NoYes value like below.

    MyFieldName = NoYes::No;

    myTableName.update;

    Thanks

    Bharani Preetham

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at

    Hi Girish,

    Sorry for the late reply, here i am adding the screenshot of UI with added control highlighted with red line .

    Please see the below screenshot and guide me .

    pastedimage1670317417857v1.png

  • GirishS Profile Picture
    27,827 Moderator on at

    Seems you have added the field at table level. So, your code should update all the sales lines against the sales header upon clicking of the button. You can use either COC or event handler. COC will be easier since you can get access to variables easily. 

    [Extensionof(formcontrolstr(FormName,controlname))]
    final class className_Extension
    {
        public void clicked()
        {
            next clicked();
            SalesTable salesTable;
            SalesLine   salesLine;
            salesTable = element.SalesTable;
            ttsbegin;
            while select for update * from salesLine
                where salesLine.SalesId == salesTable.SalesId
            {
                salesLine.checkBoxName = NoYes::No;
                salesLine.update();
            }
            ttscommit;
        }
    }

    Thanks,

    Girish S.

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at

    Hi Girish,

    Thanks for your quick reply...i will apply the same logic and will update you whether it's working or not .

    Thanks,

    Prasad N.

  • prasadn.nampalli@gmail.com Profile Picture
    45 on at

    Hi Girish,

    When i click on the cleck box it is not marked...before applying the logic,What is the cause for this why the checkbox not marked. kindly help me on this

    Thanks,

    Prasad N.

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    When you created new check box field in table, by default for all the lines it will not be marked.

    To do that you need to set the initial "value" of the check box control to 1 or add your code in the initValue method of DataSource.

    So, your functionality will work when you create new sales orders and lines after setting the initial value as mentioned above.

    For existing lines, you need to write a script to update the value of check box to marked.

    Thanks,

    Girish S.

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 289 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans