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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,902 Super User 2024 Season 2
Martin Dráb 229,316 Most Valuable Professional
nmaenpaa 101,156