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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Make a new field in form editable or not based on user selection

(0) ShareShare
ReportReport
Posted on by

Hi guys,

If lets say I have a new table, fields like : Name, Description, AllowEdit.

then I create a form for it.

I want when user change "AllowEdit" to Yes, then field description is editable, else is not. What should I do ?

I know we need to create a new class, and a copy paste from the new form -> Datasource -> table -> Fields -> AllowEdit -> Events -> OnModified then right click "Copy event handler method" to the new class. But shat should I wrote inside.

Kindly advice.

Thanks

I have the same question (0)
  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi WWong,

    I don't know if your field "allowedit" will cause ambiguity. I haven't done that because there is a property named this. I think you better modify its name.

    Your Allowedit field should be a enum field.

    if (Table.allowedit==NoYes::Yes)
    
    Table_ds.object(fieldNum(Table,Description)).allowEdit(true);
    
    else
    Table_ds.object(fieldNum(Table,Description)).allowEdit(false);;

    Write same code to  the datasource's active method.

  • Community Member Profile Picture
    on at

    O yah, it is just an example actually.

    Anyway, so I do not need to create an Event Handler Class for that ?

  • Community Member Profile Picture
    on at

    FYI, currently I create a new class, with the step I described earlier.

    After paste the code in the newly created class (it is just replace the whole thing, right ?)

    but it return an error :

    "The model element was saved with unparsable source code and cannot be used. Please edit the element in Visual Studio to fix the errors."

    and saying error in the word "void"

    Thanks.

  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi WWong,

    It mentioned that you need to copy and paste the code again.

    PLease refer this thread:

    community.dynamics.com/.../error-the-model-element-was-saved-with-unparsable-source-code-and-cannot-be-used

  • Verified answer
    Sukrut Parab Profile Picture
    71,735 Moderator on at

    Unparsable code means most probably you are missing a closing bracket  somewhere in your code.

  • Community Member Profile Picture
    on at

    Yes,

    It turned out because I replaced "all" the code, including the class name, whereby I supposed to paste only inside of the code area.

    Thanks Sukrut and Wang.

  • Blue Wang Profile Picture
    Microsoft Employee on at

    HI WWwong,

    I'm glad to hear that you have solved your problem.

    But i want to know if your original question(Make a new field in form editable or not based on user selection) has been solved.

  • Community Member Profile Picture
    on at

    Hi Blue,

    Yes, thanks.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 663

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 439 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 337 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans