web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Howto code ComandButton clicked Method in List page's action pane (to stop production jobs registration)

(0) ShareShare
ReportReport
Posted on by 46

Hello,

I have attached a new button in the ProdTableListPage's action Pane. I need to write a clicked method to stop any active jobs on the selected production record.

I only find a Command property for that button but I dont know where exacly is that method supposed to be modified/coded?

pastedimage1587389543884v1.png

Thanks a lot before hand for your kind help

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    You have two options:

    1) Add your code in the related ListPageInteraction class (you find the class name in the form's properties)

    2) Create a MenuItemButton instead of a command button, and write your logic to a separate class.

    Option 2 is better because with menu items you can link the button to security privilege and then it's possible to control access to this button via security framework. If you add a command button anyone who has access to the form has access to the button.

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Also, CommandButtons are used to launch predefined system commands, such as Refresh and Save.

    If you want a button that runs your code, you should use type Button (or even better, MenuItemButton as already mentioned).

  • CBNestor Profile Picture
    46 on at

    Hi Nikolaos,

    Let see I get it,

    for 1) I found a class called ProdTableListPageInteraction. Hi do I get to called the clicked event refering the button I have created?

    2) For a menu item, with having a main(args) that would be enough to put my code (that would be my Clicked event)?

  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    1) Quick googling resulted in this: stackoverflow.com/.../how-to-add-a-method-for-the-click-event-of-a-button-placed-on-action-pane-of-a-l

    Please note that if you add the clicked method, your list page can't be used in Enterprise Portal anymore

    2) Once your MenuItemButton is clicked, the main method of your class is executed. There you can get the prodTable record by _args.record().

  • CBNestor Profile Picture
    46 on at

    Hi Nikolaos,

    I have followed your recomendation. I added the a menuItemButton and managed to code the basis of what I need ( update the custom NoYes record after button clicked)

    1) I wonder if this code is according to the best practices or I need to improve a little bit ( used the Update_recorset instead of ttsbegin/ttscommit)

    pastedimage1587455821245v1.png

    2) How do I call the Button control, so I can disable the button after update?

  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    1) Update_recordset is not making much sense since you update only one record (since RecId is unique in each table).

    You will always need a transaction (ttsbegin/ttscommit) if you update data. No matter if you use update_recordset or not.

    2) Check ProdTableListPageInteraction\setButtonAccess

  • CBNestor Profile Picture
    46 on at

    Hi Nikolaos,

    1) I managed to follow your suggestions. At first time when clicking the button it updates the custom field and also in the list page automatically. this part is ok so far.

    2) Now I have used the JmgJobBundle class to stop any active jobs from the production selected when button is clicked. This is also doing ok. but when I try updating the field again in 1)

    throws an error that says: Cannot edit a record in Production orders (ProdTable).
    The values displayed in the form are not current, so an update or deletion cannot be made. To view the current values, on the Command menu, click Restore or press CTRL+F5.

    part of the code inspired by \Clases\JmgTermCloseOpenregTrans . createStopRegisterationJob()

    pastedimage1587566314316v1.pngpastedimage1587566634363v2.png

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    After running your logic, you should refresh the form data source by calling [formDataSource].refresh() followed by [formDataSource].research(true).

  • CBNestor Profile Picture
    46 on at

    My code is on the class called by the MenuItem as you said I have access only to Main (Args _args)

    how do i get to  the formDataSource?

    I know I ask to much but I am very close to finish . appreciated with your help

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Try _args.record().dataSource().

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 503 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans