Skip to main content

Notifications

Microsoft Dynamics AX forum
Suggested answer

Disabled field in one record in the table

Posted on by Microsoft Employee

Hello!

I want to disable field in the table, if field YesNo in the same table is No. Any ideas?

Thanks ;)

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabled field in one record in the table

    Please Keep one thing in mind this solution will be application on the form only, you cant have in on the table browser

    Please verify.

  • RE: Disabled field in one record in the table

    Could you post your actual lines of code, please (or at least table and field names). Maybe that would clarify things ;)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabled field in one record in the table

    NITESH RANJAN,  DENNIS HUESMANN thanks for your answers, but that problem is not solved :(

  • Suggested answer
    RE: Disabled field in one record in the table

    Try following code:

    YourTable_ds.object(fieldNum(YourTable, YourField)).enabled(YourValueToCheck);

    This way you do not need the AutoDeclaration flag and all occurences of the field linked to the data source are disabled/enabled depending on your condition.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabled field in one record in the table

    Go to the design of the form and location the text box related to the field

    Set the Auto declaration property of the text box as true

    let suppose text box name is TextBoxA

    so write following code in Active() method

    if(TableA.YesNO == 'No')

    TextBoxA.enabled(false)

    else

    TextBoxA.enabled(true)

    Please verify if this solves your problem

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabled field in one record in the table

    Yes, only one field in the record where other field NoYes will be no

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabled field in one record in the table

    are you looking to disable only the field?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabled field in one record in the table

    it doesn't work. I need some, like TableA.fieldToDisable.   << and after dot disable that field. Or smth like this

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabled field in one record in the table

    You can do it on form, by overriding 'Active()' method of the modify datasource table on the form

    let suppose datasource table name is TableA

    so write following code in Active() method

    if(TableA.YesNO == 'No')

     TableA.AllowEdit(false)

    else

     TableA.AllowEdit(true)

    Please verify and let me know if it works for you.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,469 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans