Saturday, 31 January 2009

Object Designer in RoleTailored Client

Here’s a bit of fun for anyone that wants to play around with development in the new Virtual PC image for NAV 2009. I’ll take you through building an Object Designer page in the RoleTailored client. Obviously there are some things you won’t be able to do (like actually design objects) but you will find it useful – I have done – and it’s a good exercise to follow. Here’s an example of the end result.

As you may know, you can run pages (and some other objects) in the RoleTailored client by using a hyperlink command entered into your browser address bar. The thing is, I often can’t remember the syntax, and need to open my book (because I know I wrote the details there). You could also find the answer by searching the online help or searching blog posts. The syntax I use is: dynamicsnav:////runpage?page=358 as this will launch the page in my default company. Typically, I want to create a quick page or try something out without going to the trouble of adding the object to the MenuSuite, then finding it in the Departments Page and running it, so I use this hyperlink command. It works OK, but I figured it would be good to have a list place of objects that I could use in the RoleTailored client to run any page.
For a start, we’re going to need an Object Designer page. This exercise is based on the new virtual PC image for NAV 2009 – (you’re going to need a Developer’s License installed before you can do this exercise).

1) Launch the Classic Client with SQL Server and make sure you are running with a Developer’s license.

2) Run the Object Designer (Shift+F12), click the Page button to work with Pages in the Designer and click the New button to create a new Page.



3) In the New Page window enter Object in the Table field and select the option create a blank page of type List. Click OK.



4) In the Page Designer, you have a blank line. The top line needs to be a ContentArea Container, and the quickest way to get one in there is to put something in the Caption field, move off the line and then move back on to it and delete the contents of the Caption field.

5) Now on the next line down, create a record of type Group and SubType Repeater. This is how we get a table type control in a list. Move down to the next blank line. Your page should look like this.



6) Now click on the Field Menu button from the toolbar or select View | Field Menu from the menu bar.



7) Highlight each of the lines except the BLOB field. Then click back on to the Page Designer. It’s not a drag-and-drop, but more like a click-and-click.

8) The system will ask if you want to add the selected fields to the page. Select Yes while mumbling “duh?” to yourself. Your page should look something like this.



9) Now would be a good time to save your work. Hit Ctrl+S and enter Object ID 60000 and call it Object Designer. If you didn’t load your developer’s license on the Virtual PC image, you’re going to be pretty grumpy now.



10) I don’t want all of those fields to be immediately visible, but it’s nice to have them on the Page just in case I want to use them but we can hide them by setting the Visible property. For example, with your cursor on the Company Name field, press Shift+F4 to bring up the properties and set the Visible property to FALSE.



11) Change the Visible property to FALSE for DBM Table No. and Caption too. Save your changes again with Ctrl+S.

12) Now we want to add the ability to run our objects so we need an Action on the page. Move your cursor on the Page Designer so that it is on a blank line and select Actions from the View menu (if you are on a blank line this will give you Actions for the Page which is what we want).

13) Create a new ActionContainer with a SubType of ActionItems and then on the next line create an Action of type Action with a Caption of Run. We want to set some properties on this Action so that it will appear in our Action Pane when we run the Page.



14) Set the Image property to Start (that’s the name of the image), Promoted to Yes, and PromotedIsBig to Yes. I also set the PromotedCategory to Process.

You could try running our new page now with dynamicsnav:////runpage?page=60000 but you will discover that our Action Button does not appear. This is because we don’t have any code or properties against the button that will do anything. We also want to filter our records so we only see objects with a Type greater than 0. Let’s continue where we left off. First of all we’ll filter the records to only show a limited range of object type.

15) We need to set the SourceTableView property for the Page, so with a blank line on the Page Designer selected, press Shift+F4 to bring up the Page Properties.



16) Type WHERE(Type=FILTER(>TableData)) into the SourceTableView field (you can use the assist edit buttons to figure out this value if you wish, or you can just type it straight in to the field).

17) Close the Properties window and with the blank line still selected, bring up our Actions once more. This time, press F9 on our new Action when it appears to bring up the C/AL Editor window.

18) Enter the following Code.



19) Save everything with Ctrl+S and try to run our Page with dynamicsnav:////runpage?page=60000. Bingo. If everything worked OK, you should have something like this.



Nearly there. Just one tiny change to make. I’d like my new list to be available as a List Place in my Role Center, so I’m going to modify the default Role Center (on the Virtual PC image) which is Page 9018.

20) Edit page 9018 and with a blank line selected, bring up the Actions window to show the Actions for the Page.

21) Insert a new Action in the HomeItems Action Container. Type must be Action and set the Caption to Object Designer.



22) Finally, set the RunObject property for the Action to Page 60000, the system will translate that to Page Object Designer as you move off the field (assuming you have followed these instructions).

23) Save everything and restart the RoleTailored client (unfortunately the Refresh button doesn’t re-read the Role Center so we need to re-open the RoleTailored client).

24) That’s it. Our very own RoleTailored Object Designer. Well Object Runner really, but hopefully you learnt a few things along the way.

If you want the tool but not the learning experience, you can download the objects from DUG. As a matter of interest, you can use Mark Brummel’s discovery about running the Classic client reports from the RoleTailored client to run Forms as well. Maybe I’ll post that another day.

No comments: