Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

where should I put code to disable a button on a form

(0) ShareShare
ReportReport
Posted on by 312

Hi,

I would like to disable a button on salesQuotationtable under some conditions.

but I have problem to find where to put my code 

button.enable(false);

I try to put it in active method of datasource.

I debug and make sure it did run the code. however maybe it changed status after I setup.

I open the form the button is still enabled.

so I would like to know is there a place to put the code under this scenario?

P.S : I read this article : event method sequence when a form is open

(https://msdn.microsoft.com/en-us/library/aa608211.aspx

it does even include active() method , why?

Thanks for all the answer

Quatrani

 

*This post is locked for comments

  • Verified answer
    Srini Ramidi Profile Picture
    Srini Ramidi 2 on at
    RE: where should I put code to disable a button on a form

    Hello,

    Confirm button is enabled/disabled based on the value of method “mayConfirmationBeUpdated” in class “SalesQuotationTableType” so you better add your logic to “SalesQuotationTableType” method to enable/disable the button.  This way you don’t need separate code for Quotation form and list page.

    Best,

    Srini

  • Suggested answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: where should I put code to disable a button on a form

    Hi,

    Confirm button on form SalesQuotationTable is driven(enabled/disabled) in the method enableHeaderUpdateActions. Place a breakpoint in this method and check which condition is enabling the button.  

    This method is called in the following methods on form:

    \Forms\SalesQuotationTable\Data Sources\SalesQuotationTable\Methods\active

    \Forms\SalesQuotationTable\Data Sources\SalesQuotationTable\Methods\

    selectionChanged

    \Forms\SalesQuotationLine\Data Sources\SalesQuotationLine\Methods\active

    \Forms\SalesQuotationLine\Data Sources\SalesQuotationLine\Methods\

    selectionChanged

  • JCHI Profile Picture
    JCHI 312 on at
    RE: where should I put code to disable a button on a form

    Hi, Crispin:

    Thanks.

    The condition is:

    When the sales Quotation is generated, we write the quotation data to another system. then we have to prevent user to modify the quotation until feedback from another system.

    So what I actual want to do is prevent user to modify sales quotation

    I add code

    salesQuotationTable_DS.allowEdit(false),

    salesQuotationTable_DS.allowDelete(false)

    salesQuotationLine_DS.allowEdit(false),

    salesQuotationLine_DS.allowDelete(false)

    in active() of form datasource. which is fine.

    However I find confirm button in follow up tab of SalesQuotationTable(detailPage) is still enabled.

    So I want to disable it. when another system status of this quotation is send

    Do you have any suggestion? thanks

  • Suggested answer
    Mahmoud Hakim Profile Picture
    Mahmoud Hakim 17,887 on at
    RE: where should I put code to disable a button on a form

    you can put your code in init() method for your form

  • Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: where should I put code to disable a button on a form

    Hi,

    Could you provide some more information about your conditions/requirements, such that we can help you better.

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 Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans