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)

Updating marked record from an InMemory table form data source

(0) ShareShare
ReportReport
Posted on by 2,699

Hi All,

Having a little trouble trying to achieve the following:

I have created an InMemory table that is populated by a query.

The query is initalised when the form opens and the data is populated successfully into the form datasource.

This all works fine.

However, what I want to achieve is mark multiple records from this data source, pass them into a method for update and change a boolean data value in the marked records, then refresh the form to display this?

Can someone advise?

*This post is locked for comments

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

    What problem do you have with it? Can you show us the code you tried to use?

  • Kauto Profile Picture
    2,699 on at

    Here is the code behind the button which handles the marked records Martin, I had originally used this when the table was a standard table but it is now an InMemory one so I have changed the code slightly but you will get the jist of what I'm trying to achieve here.

    Thanks for looking at this

    void clicked()

    {

       CustomTable                                marking;

       CustomRemoveTable                   removal;

       MultiSelectionHelper                   selectionHelper = MultiSelectionHelper::construct();

       ;

       if (Box::okCancel('Are you sure you wish to perform this?', DialogButton::Cancel) == DialogButton::Ok)

       {

           ttsBegin;

           selectionHelper.parmDatasource(CustomTable_DS);

           marking  = selectionHelper.getFirst();

           if (marking.RecId)

           {

               // loop through selected marked records and insert removal data then update record

               while (marking)

               {

                        // insert details of record for deletion if it is already there ignore it

                       try

                       {

                           // capture details in secondary deletion table

                           removal.clear();

                           removal.initValue();

                           removal.ItemCoverageRecId       = marking.ItemCoverageRecId;

                           removal.CovDataAreaId              = marking.CovDataAreaId;

                           removal.Processed                      = false;

                           removal.insert();

                           // delete marked record so user sees them being removed from their original selection

                           marking.selectForUpdate(true);

                           marking.MarkedForDelete = true;

                           marking.doUpdate();

                       }

                       catch(Exception::DuplicateKeyException)

                       {

                           continue;

                       }

                      marking = selectionHelper.getNext();

               }

           }

           ttsCommit;

           // refresh the datasource after completion

           CustomTable_DS.research(true);

       }

       super();

    }

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

    All right, so what's the problem with your code? Where does it fail? Already in getting the first record, or somewhere else?

  • Kauto Profile Picture
    2,699 on at

    I get the Error In File:

    reading in record EA8A0

    Error Code 38 = fileName too long

    Try again?

    When I hit no I then get:

    Cannot edit a record in Item coverage marking for removal (CustomTable).

    The record has been deleted by another user.

  • Kauto Profile Picture
    2,699 on at

    My issue is Martin, I am unsure how to ensure the marked records from my temporary table datasource get updated

  • Kauto Profile Picture
    2,699 on at

    It fails on the following:

    // delete marked record so user sees them being removed from their original selection

                          marking.selectForUpdate(true);

                          marking.MarkedForDelete = true;

                          marking.doUpdate();

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

    Which line is giving the error "reading in record EA8A0"?

  • Kauto Profile Picture
    2,699 on at

    when doUpdate() is called

  • Kauto Profile Picture
    2,699 on at

    The first marked record passed in from the datasource

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

    Do you actually want to support deletions? If not, maybe you can simply override delete() to do the update.

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