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 :
Microsoft Dynamics AX (Archived)

Setting form to view (not edit) mode in code

(0) ShareShare
ReportReport
Posted on by

In brief, I have a form which normally opens up in edit mode.

Under certain circumstances (if a certain field is true), I want the form to open in view (not edit) mode.

Do I need to add code to the init method on the form, or the active method on the datasource? In either case, how do I programmatically toggle between edit and view mode? Also, how do I programmatically know if I am currently viewing or editing a record?

Thanks for any assistance,

Bill Yater

Blue Horseshoe Solutions, Inc

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Florian Hopfner Profile Picture
    2,466 on at

    ViewEditMode is a property of the form design. If your form displays only one record, you should use the init method. If it shows several records and the ViewEditMode should change depending on the selected record, you should use the active method. You can use element.inViewMode() to determine if you are in view mode.

    See also http://axbloggerblog.blogspot.de/2012/07/ax-2012-view-and-edit-mode.html

  • Community Member Profile Picture
    on at

    Fh-inway,

    Thank you for your help. I went to the AXBlogger article in your link, and found the element.inViewMode() statement.

    That did the trick in letting me detect if I was in View or Edit mode.

    I was even able to use that in my Edit button's clicked method, so I can do some pre-editing checks if they are currently in View Mode and about to edit a record.

    My form does only show one record at a time.

    I also tried to add the following code to my form's init method:

       if (my condition check return true)

       {

               //  Set the form to view mode

               element.design().viewEditMode(ViewEditMode::View);

       }

    This does set the form to view mode, but then I can't ever edit the record shown, even when I click the Edit button.

    I'm sure I'm not the only person who has to programmatically switch between View and Edit mode at runtime.

    Any other thoughts?

    Bill Yater

    Blue Horseshoe Solutions, Inc

  • Suggested answer
    Yev Profile Picture
    35 on at

    call the following code to switch to edit mode from X++:

    element.task(4471);

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans