All around NAV dev and test
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.
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:
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!
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'.WshShellIn OnOpenPage Trigger:...IF ISCLEAR(WshShell) THEN CREATE(WshShell,FALSE,TRUE);WshShell.SendKeys('^+V');//Ctrl+Shift+Vhere 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!
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.
Nice blog Luc! The solution is quite "dirty" but if it works, it's fine with me!
I did some investigation and according to me the problem can be solved by using standard NAV properties (and without Windows Scripting Host):
Settings on the List Page:
1. Set the Page property CardFormID to the correct Page ID (Why is this property not named 'CardPageID' ?)
2. Set the Page property Editable to No (otherwise the double click will not work).
3. Create an Action that opens the Card in View mode, using the Action properties RunObject, RunFormLink and RunFormMode.
4. Set the Action property ShortCutKey to Return. (Thanks to Mark: dynamicsuser.net/.../tip-23-the-return-shortcut.aspx)
Now you have an action that opens the Card in View mode *and* this action is the default action that is performed when you double click a row in the List. This action is also added to the context menu of the rows, in bold!
The other actions (Open in View or Edit mode) in the contect menu are still available.
Good luck, 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.
The Edit/View actions on the contect menu will be removed when you don't specify the CardFormID on the List Page.
Result: only the new created action will be on the context menu.
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
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.
That's too bad, Luc. And it will not be included in the TIF tool in the future as MSFT has planned to not maintain the TIF tool in future version.
Instead they are planning to come up with a better Page designer and leave Forms behind.
So in this case you still have to do some manual work after transformation.
Thanks Arend-Jan, that helped me a lot. I wanted to open in view mode from a list so that user can choose to edit if required. Now I can do it.
Its not a big deal to have an additional action..I just called it 'Open' and assigned the View Image.
Its a pity that there is no DefaultMode property for a page which would work in the same way as RunFormMode in actions, when the double-click from the list occurs.
Anyway, thanks again.
Has your request be included in the Nav2013 Beta Version?
If not, I will make a seet-in in front of my office 'til it's done...
Hi Julien, not that I know of so go ahead ;-)
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.
I think better ,
IF "No."='' THEN WshShell.SendKeys('^+E')
when page open for new record
I don´t find the way to set de open mode of card page from a list page, in NAV8 (less in NAV7)
Me neither ... Guiyote.
still nothing in NAV2017 :( ?