How-to: Set View Mode on Pages as Default

One technical incident we posted to MS some weeks ago which might be of interest to you. Initially I posted it on mibuso.com, but did not get a satisfactory reply on that. You will however find the workaround suggested by the MS engineer to me also on this post as she later copied it on this post. [Y]

Issue

Our add-on I-Fresh has a generic feature that by default opens certain forms as not editable, to avoid that users accidentally start typing and modifying any data. Simply pressing a button enables the user to bring it into edit mode. Getting I-Fresh RTC ready it became apparent that we needed to redesign this feature as it could not be transformed straight forward. Instead of keep-on-trying to get it transformed one way or another, we wanted a different approach, recalling the fact that pages can be opened in either View or Edit mode.

Likewise the Customers list place – view mode:

Likewise the Customer Card task page – edit mode:

Solution

Logically we thought that this would be our solution: make sure those pages open in view mode and by using the Action or Contextual menu the user would be able to bring it from view to edit mode:

But we could not find a standard way – a property or C/AL method – that would allows us to open, for example, the Customer Card task page in this view mode. Although we were quite sure that it could open in view mode as running it from the Object Designer does open it in view mode:

And … the page can than be brought into edit mode through the Action menu!

Workaround

After reporting our issue, within 1 day (!) we did get a proper workaround as indeed the RTC platform currently does not support this altogether.

Here it is, copied from our service request:

… we found a workaround, this I tested out using Windows Scripting Host Automation and SendKeys in the OnOpenPage Trigger to toggle the Editable Property for the Page and it worked.
However this is NOT SOMETHING I CAN SAY MICROSOFT RECOMMENDS or have tested on a larger scale.
Anyway, this is a sample of what I tested.


Declare WshShell as Automation Variable for ‘Windows Script Host Object Model’.WshShell
In OnOpenPage Trigger:

IF ISCLEAR(WshShell) THEN
  CREATE(WshShell,FALSE,TRUE);
WshShell.SendKeys(‘^+V’);//Ctrl+Shift+V

here the command for the Edit:
WshShell.SendKeys(‘^+E’) //Ctrl+Shift+E

And yes, we tested it also and it’s working OK. Thanx Microsoft! Thanx Ariella Benchetrit! [^]

Future

Nevertheless, I was not fully satisfied so, although very much pleased with their effort so far, I could not just live with the fact that it’s not simply supported and so I decided to push back still. To be honest I had no high expectation, but I just wanted to give off some kind of message as I was:

… still a bit flabbergasted as running a page from the object designed (see my repro steps) the page is clearly launched in View mode (and the user can change it to Edit mode); so somehow NAV supports this.

 And yes, no real solution, but a promise, for whatever it is worth:

… this is in feature requests list and could be included in next NAV 7

Note: could! Help me hope it will.[8-|]

6 Comments

  1. Hi Arend-Jan,

    Great effort. Thanx for that.

    A pitty I cannot hide this new action. It would even be better if the Edit/View actions were available in the Action Designer so we could set ShortCutKey to Return for the View action.

    b rg

    Luc

  2. Based on your input, Arend-Jan, I continued to find an efficient way to implement this as part of the Form Transformation process. So, in the TIF tool, I:

    1.- Emptied the CardFormID for the Customer List (indeed not default View and Edit actions are created

    2.- Created an adddtional action called View (!) with:

    ActionsType = ActionItems

    CaptionML = ENU=View

    RunObjectType = Page

    RunObjectID = 21

    RunFormLink = No.=FIELD(No.)

    RunFormMode = View

    3.- Created TIF files for forms 21 (Customer Card) and 22 (Customer List)

    4.- Created Forms.xml for same forms

    5.- Transformed forms and impotred (and compiled) newly created pages

    Result:

    Customer List list place:

    + without default View and Edit Action

    + with new View action

    BUT: unfortunately the new View action is not provoked by double clicking a customer record (line) or using the Enter key as the ShortCutKey property canNOT by initiated by the TIF data! That's a pitty.

  3. Hi Julien, not that I know of so go ahead 😉

  4. I did check with my MVP buddy Damian and this what I got as an answer:

    No, it is not possible to change the view mode from the application code today. There is a property on the Actions called RunMode where you can specify the view mode but this is only for when the form is opened through an action.

    We are working on a solution for it in Nav8.

  5. Me neither … Guiyote.

Leave a Reply

Your email address will not be published. Required fields are marked *