I'm new to developing in Microsoft Dynamics 365FO and I'm having some trouble with opening a new form and sending my selected field to it.
I'm currently making a Complaints form where it is possible to enter complaints about orders.
I want to add a button to the SalesTable which redirects you to the complaints form and enters the information of the selected field in the complaints form.
Right now I made a form extension of the SalesTable and added a MenuItemButton. I also made a Class called SalesTableEventHandler that should trigger when the button is clicked that contains the code below.
In this class I have some code that keeps giving me errors that is not able to find my class, table or an extended data type.
The form is called ComplaintRegistrationMaster and the table ComplaintRegistration.
I would like some help with either fixing the error so I can continue or with someone suggesting a better way to do this.
public static void OnMenuItemButtonClick(FormRun _formRun, Object sender, FormDataSourceEventArgs e)
{
SalesTable salesTable;
ComplaintRegistrationMaster registrationForm;
salesTable = _formRun.dataSource().cursor();
registrationForm = new ComplaintRegistrationMaster();
registrationForm.init();
registrationForm.queryBuildDataSource().addRange(fieldNum(SalesTable, SalesId)).value(salesTable.SalesId);
registrationForm.queryBuildDataSource().addRange(fieldNum(SalesTable, CustAccount)).value(salesTable.CustAccount);
registrationForm.run();
}
error one:
Severity Code Description Project File Line Suppression State
Error The name 'ComplaintRegistrationMaster' does not denote a class, a table, or an extended data type. ComplaintRegistration (USR) [ComplaintRegistration] C:\AOSService\PackagesLocalDirectory\Bin\XppSource\ComplaintRegistration\AxClass_SalesTableEventHandler.xpp 6
error two:
Severity Code Description Project File Line Suppression State
Error Class 'ComplaintRegistrationMaster' was not found. Are you missing a module reference? ComplaintRegistration (USR) [ComplaintRegistration] C:\AOSService\PackagesLocalDirectory\Bin\XppSource\ComplaintRegistration\AxClass_SalesTableEventHandler.xpp 10
Your design looks wrong to me. The usual approach is using a menu item to open the form and if there is a relation between those tables, a filter is applied automatically.
And if you need custom logic. you usually put in the target form. this.args().record() will give you the active record from the caller form and you can add a query range for it.
The error suggests says that no type called ComplaintRegistrationMaster is visible for your code. In this case, the likely reason is that you have only a form, which can't be used as a type in X++. If you wanted to create a form instance from code, you should use classfactory.formRunClass().
By the way, please use Insert > Code (in the rich-formatting view) to paste source code. It preserves line indentation, among other things.
Hi DaanBerkhout,
CompalintRegisterMaster is in which model?
Also, SalesTableEventHandler is in which models?
Thanks,
Girish S.
Martin Dráb
456
Most Valuable Professional
Abhilash Warrier
310
Saalim Ansari
261