Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Adding a button to SalesTable which sends data to a custom "Complaints" form.

(0) ShareShare
ReportReport
Posted on by 5

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


  • Martin Dráb Profile Picture
    233,675 Most Valuable Professional on at
    RE: Adding a button to SalesTable which sends data to a custom "Complaints" form.

    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.

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Adding a button to SalesTable which sends data to a custom "Complaints" form.

    Hi DaanBerkhout,

    CompalintRegisterMaster is in which model?

    Also, SalesTableEventHandler is in which models?

    Thanks,

    Girish S.

Under review

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

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 456 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 310

#3
Saalim Ansari Profile Picture

Saalim Ansari 261

Overall leaderboard

Product updates

Dynamics 365 release plans