Throw behaviour in X++
· 3 min read
References
How to
Prerequisite
For the purpose of testing, I had this data set of CustGroup. This can also be found on Legal Entity USRT
of demo data comes with a new environment of Dynamics 365 Finance.
Customer group | Description |
---|---|
10 | Wholesale customers |
20 | Major customers |
30 | Retail customers |
40 | Internet customers |
50 | Employees |
80 | Wholesale customers |
90 | Wholesale customers |
I added two new buttons on CustGroup
form:
Bulk update Desc
: This button will loop through each and all records in the above table and update the Description to Description ++ Updated
except one containing "Employee". They will become like below.
Customer group | Description |
---|---|
10 | Wholesale customers + Updated |
20 | Major customers + Updated |
30 | Retail customers + Updated |
40 | Internet customers + Updated |
50 | Employees |
80 | Wholesale customers + Updated |
90 | Wholesale customers + Updated |
Reverse Bulk update Desc
: This button will update all Description back to its original by removing the word+ Updated
.
Let's do it
When we don't use throw
In the extension class named CustGroup_ButtonHandlers
, I put these codes which will handle the event of clicking those two buttons.
tip
This type of FormControlEventHandler
will only be needed when you are extending a standard form. For a totally custom form, you can add a Clicked() method method for any buttons on the form.