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)

Validating records,resetting to original values

(1) ShareShare
ReportReport
Posted on by

Hello, here's a scenario, in the validatewrite method of a table, I check a field, if some conditions are not met, user should not be able to update the table, this works flawlessly, however the problem is, I also want to revert the value of a field to its original value, how can i achieve that?Because if the user updates multiple records in a grid and leaves the grid, the error message shows up and unless the user returns the values to their original values, he keeps getting the same error.

For example:

public boolean validateWrite()
{
    boolean ret;
    erm_ItemIdentQuotTable table;



    select firstOnly ItemIdentQuot from table where table.QuotNo == this.QuotNo;
    if (table.ItemIdentQuot == ItemIdentQuot::Created)
    {
        ret = super();
    }
    else
    {
        return checkFailed(strfmt("%1","You can only update newly created records"));
    }

    return ret;
}


*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at

    you can try

    table.ItemIdentQuot = table.orig().ItemIdentQuot;

    Regards

    jonathan

  • Community Member Profile Picture
    on at

    Well,user could update any of the fields,so my best option is to reread() them all i guess.Thanks for the reply.

  • Community Member Profile Picture
    on at

    The requirement is not absolutely clear to me, but you should do this in validateField for the affected fields. If validateField returns false it will rollback the field automatically.

  • Verified answer
    Community Member Profile Picture
    on at

    Well the problem is, we wouldn't know which field the user had updated, so i went ahead and used reread() for the data-source.

    regards.

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