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

Notifications

Announcements

No record found.

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,461 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans