web
You’re offline. This is a read only version of the page.
close
Skip to main content
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


I have the same question (0)
  • Martin Dráb Profile Picture
    235,979 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 844 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 752 Super User 2025 Season 2

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 553

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans