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 :
Microsoft Dynamics AX (Archived)

Update check box field in grid

(0) ShareShare
ReportReport
Posted on by

Hi guys, I am trying to update a check box field in my grid by using a button clicked method.

How should I do it?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    If your checkbox is bound to a datafield you can put following code in your clicked method

    <datasourcename>.<fieldname> = NoYes::Yes

    If it is not bound to a datafield and the name of your checkbox column is for instance ValueChecked put following code in your clicked method on the button

    ValueChecked.Value(1);

    In the properties of the ValueChecked checkbox, set AutoDeclaration to YES to be able to use it in the coding.

  • Community Member Profile Picture
    on at

    Hi Pvanstilpelen,

    I only can updated the first record. How about if I have 10 records in the grid view?

    I am using "<datasourcename>.<fieldname> = NoYes::Yes"  this code.

  • Verified answer
    Steeve Gilbert Profile Picture
    1,501 on at

    Use <datasourcename>_ds.getFirst() and <datasourcename>_ds.getNext() to browse the record.  Modify each record and call write() so save the change.  You will maybe need to call <datasourcename>_ds.refresh too see the change on the form.

  • Verified answer
    Community Member Profile Picture
    on at

    In addition to Steeve's guidance, you can use <datasourcename>_ds.research() only once at the end of the process to update the display of all modified records.

    Regards,

  • Community Member Profile Picture
    on at

    Hi Steeve,

    Below is my code:

    void clicked()

    {

       int i;

       xinit_CustomerDet custdet;

       ;

       super();

       xinit_CustomerDet_ds.markAllLoadedRecords(1);

       custdet = xinit_CustomerDet_ds.getFirst(true);

       while (custdet)

       {

           custdet.Active = NoYes::Yes;

           custdet.write();

           custdet = xinit_CustomerDet_ds.getNext();

       }

       xinit_CustomerDet_ds.research(true);

    }

    I can updated the record but it did not updated all. In my grid, i have over 100 records, it always updated until half of it. And i have to click again button to trigger the function and update. Is there any solution to solve this?

  • Verified answer
    Community Member Profile Picture
    on at

    Hi,

    I guess the problem is in markAllLoadedRecords(). It seems records in a grid are progressively loaded (retrieved from database) as you scroll it.

    Instead of markAllLoadedRecords, try this:

    <Table>   record;

    for (record = <dataSource>_ds.getFirst(); record; record = <dataSource>_ds.getNext())

    {

       ...

    }

    <dataSource>_ds.research(true);

    If your code isn't dependant on filters set on the datasource, You can update the table directly with a while select forupdate.

    You could also retrieve the query from <datasource>_ds.queryRun() and retrieve the records with it. This will work similarly to the code I posted above.

    Regards,

  • Community Member Profile Picture
    on at

    Thank you Leandro, This is the answer I need.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans