Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to make field editable based on condition

(0) ShareShare
ReportReport
Posted on by 920

i have a form with a grid. when the grid is populating its data, i want to change yes/no enum field to yes. when I change this field another field became editable. Example, If FieldA == Yes then FieldB.allowedit(true). 
i put the code into the datasource's active method, but it doesn't work
please advice?

this is my code : 

if (SPLCalculRistourneMois.objectif==NoYes::Yes)

SPLCalculRistourneMois_ds.object(fieldNum(SPLCalculRistourneMois,TauxRistourne)).allowEdit(true);

else
SPLCalculRistourneMois_ds.object(fieldNum(SPLCalculRistourneMois,TauxRistourne)).allowEdit(false);

*This post is locked for comments

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to make field editable based on condition

    Thanks Mariano,my problem is solved.

  • RE: How to make field editable based on condition

    If the table field has the property allowedit to false you will never be able to edit it even with your code, you must allow to edit it and then control the property by code

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to make field editable based on condition

    hi Jonathan,

    Yes i put the code in the active method and in the modifiedField but i have the same problem,

    the field editable has the property on the table"allowedit=false"

  • Jonathan  Halland Profile Picture
    Jonathan Halland 11,306 on at
    RE: How to make field editable based on condition

    BASMA.

    As per Mariano's suggestion you need both. The "active" will handle when you move from row to row and want to set the fields property based on existing value. The "modifiedField" will set the editable status based on what you have just changed.

    Maybe if you put you code from both these methods in it may be useful.

    Can you also confirm what the actual field's editable state is on the table?

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to make field editable based on condition

    Hi Mahmoud,

    thanks fo your reply but i have the same problem.

  • Suggested answer
    Mahmoud Hakim Profile Picture
    Mahmoud Hakim 17,887 on at
    RE: How to make field editable based on condition

    You can check this link

    axaptadevmallik.blogspot.ae/.../form-field-allow-edit-based-on-conditons.html

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to make field editable based on condition

    I add this code in the modified method of field "objectif" but the same problem?

  • RE: How to make field editable based on condition

    No, indeed you need it

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to make field editable based on condition

    Hi mariano,

    I delete this code from the active method?

  • Verified answer
    RE: How to make field editable based on condition

    You almost have it, write the same code in the objectif datasource field modified method

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,759 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans