Skip to main content

Notifications

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,902 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,316 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans