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
call the following code to switch to edit mode from X++:
element.task(4471);
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
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,188 Super User 2024 Season 2
Martin Dráb 230,030 Most Valuable Professional
nmaenpaa 101,156