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 :
Dynamics 365 Community / Forums / Finance forum / How can I only Enable/...
Finance forum

How can I only Enable/Disable menu Button?

(0) ShareShare
ReportReport
Posted on by 962

Hi

I successfully enabled a Button group in Return Table form with following code. So I thank the code can work. However, in the beginning, I plan to only unable a menu button "buttonUpdatePackingSlip" which is one of numbers in "GroupProcess". When I changed GroupProcess to buttonUpdatePackingSlip, my code does not work sometimes. I found the "buttonUpdatePackingSlip" is also called in another place.  So, it affects my code. How can I let my code in Form extension run in the last step?

formrun.control(formRun.controlId(formControlStr(ReturnTable, GroupProcess))).enabled(false);

Best Regards,

JustZM

I have the same question (0)
  • Anton Venter Profile Picture
    20,345 Super User 2025 Season 2 on at

    Hi JustZM,

    You have to find all the references to "buttonUpdatePackingSlip" and figure out when your code should be called.

  • Sukrut Parab Profile Picture
    71,710 Moderator on at

    Did you try to search where  button buttonUpdatePackingSlip enabled /disabled on that form ? You have to perform your action once standard  method is executed.

  • Blue Wang Profile Picture
    on at

    Hi JustZM,

     

    Look at the method 'enableUpdateJournalButtons()' in the class 'PurchTableForm', Please.

    This method controls the enable/diable state of all these buttons.(buttonUpdatePurchaseOrder,  buttonUpdateReceiptsList, buttonUpdatePackingSlip, buttonUpdateInvoice).

     

    if (isCustomsEnabled)
    
    {
    
        ...
    
    }
    
    else if (!isCustomsEnabled
    
        && purchTable_W.CustomsImportOrder_IN
    
        && _buttonUpdatePurchaseOrder
    
        && buttonUpdateInvoiceRegistration
    
        && buttonUpdateBillOfEntry
    
        && _buttonUpdateReceiptsList
    
        && _buttonUpdatePackingSlip
    
        && _buttonUpdateInvoice)
    
    {
    
        _buttonUpdatePurchaseOrder.enabled(false);
    
        buttonUpdateInvoiceRegistration.enabled(false);
    
        buttonUpdateBillOfEntry.enabled(false);
    
        _buttonUpdateReceiptsList.enabled(false);
    
        _buttonUpdatePackingSlip.enabled(false);
    
        _buttonUpdateInvoice.enabled(false);
    
    }

  • Suggested answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    These standard list pages have a straightforward logic and you should try to put your code aligned with existing code and not something on formrun etc.

    Please have a look at next method.

    \Classes\SalesTableType\canPackingslipBeUpdated

    If you would not respect the existing code, things may or may not work sometimes (as you have mentioned earlier in your original thread) 

    Respect the existing code. 

  • JustZM Profile Picture
    962 on at

    Hi All

          Thanks for your reply. After go thought code. I found where is the system code to enable/unable buttonUpdatePackingSlip in return Table. I found, if my code can run after system code, my function will work. But how can I let my code run after system code. 

          The system code is executed in ReturnTable(form) -> SalesTable(form data source)-> selectionChanged(). After finish selectionChanged(), the code will move to next function under Salesline(form data source.)

          How can I make my code is aligned with excited code or run before/after some function?

          Is there any link, I can learn that?

    Best Regards,

    JustZM

  • Suggested answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    You can do COC on that method and write your code as per your business requirement .

  • JustZM Profile Picture
    962 on at

    Hi 

          I tried to create a COC, and set System code run before my code. But I failed with error. It's not a COC Method.

          How could I fix it?

    Best Regards,

    JustZM

    42.png

  • Suggested answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    You are trying to implement coc in event handler . Just look at standard documentation for a syntax.

  • JustZM Profile Picture
    962 on at

    Hi Sukrut

         If I cannot use COC in event Handler, I have two questions.

         First: the SelectionChanged() is function under Form DataSource, "public void selectionChanged()". Can I used COC for this function? I followed documentation, and it shows same error, either I add public before void or not.

         second: If I do not use event handler, how can I let form knows which record I am checking.

         I am kind of confuse about those questions. Thanks for your help.

    Best Regards,

    JustZM

    43.png

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

    To use CoC on form data source, you must create a class like ExtensionOf(formDataSourceStr(FormName, DataSourceName))...

    Then you can refer to the data source as "this" and get current record with "this.cursor()".

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans