web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

how to set the previous value on grid if modified value was not meet the requirement.

Posted on by 10

Hi, Readers!

I have a question how to set the previous value on grid if modified value was not meet the requirement.
I added grid which has a Quantity field on regular form.
That grid value is based on created table.
I would like to have an error if new quantity was larger than original quantity.
Also, I would like the Quanity value on grid to be changed to previous value by automataically, if I put the large value.

(For Example,
①Error:original quantity = 10, new quantity = 20 ⇒Error ⇒Value of Quantity field on the grid = 10
②Success:original quantity = 10, new quantity =5 ⇒ successfully ⇒Value of Quantity field on the grid = 5)

Here is my source that I have already tried.

I could set the previous value when I changed original value to small value then changed large value.
For Example, original quantity = 10, new quantity =5 ⇒ successfully ⇒Value of Quantity field on the grid = 5 ⇒ new quantity = 20 ⇒ Error ⇒Value of Quantity field on the grid = 10.

However, I could not set the previous valur when I changed original value to large value.
For Exmample, original quantity = 10, new quantity =15 ⇒ Error ⇒Value of Quantity field on the grid = 15.(But it is supposed to be 10.)

[FormControlEventHandler(formControlStr(SalesEditLines, SalesOrderedQty), FormControlEventType::Modified)]
public static void SalesOrderedQty_OnModified(FormControl sender, FormControlEventArgs e)
{
if(newQty > originalQty)
{
sender.formRun().dataSource().cursor().SalesOrderedQty = originalQty;
sender.formRun().dataSource().cursor().ExtendedAmount = originalQty*sender.formRun().dataSource().cursor().BaseAmount;
Error("The new value is larger than original value");
}
}

If anybody knows how to solve this, please let me know.
Thank you for your help.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
Basit Profile Picture

Basit 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans