Saturday, January 19, 2013

Part 3, step by step developing Visual Studio 2012 LightSwitch application.

This is the last part in this blog, below are the links to the previous parts:
Integrating Visual Studio 2012 LightSwitch and Dynamics NAV OData (Part 1)
Step by step developing Dynamics NAV objects (Part 2)

3- Build Visual Studio 2012 LightSwitch Html Client application
Create a new LightSwitch HTML Application, and Save it.




4- Add NAV OData to
Right click on Server Node in Solution Explorer and click Add Data Source..., select OData Service and click next.




Enter http://localhost:7048/DynamicsNAV70/OData/ in Specify the OData service endpoint and keep attach to this data source as read-only checked.



Click next and expand Entities node then select Customer & SalesPerson entities, note we won't require selecting Company entity since we have one Company in NAV database (Cronus International Ltd.). Click finish.



Expand Server node, then expand NAVData node to see the selected entities listed up there. You may close Application 1 Designer* Tab in the designer tab area.





5- Build Sales Persons & Customers browsing screen
Right click Client (Startup) node and click on Add Screen. In Add New Screen select Browse Data Screen and in Screen Data drop down list select NAVData.SalesPerson and click OK.



Press F5 to run the application, we haven't finished yet, but to only to see how Sales Persons screen is displayed by default.




Close the browser (above screen) and go back to Visual Studio screen. Click Sales Person Node and select Rows Layout.



Click on SalesPersons DataItem (Left Panel) and click Add Data Item... in the designer tab.




From Add Data Item screen select Query option, and NAVData.Customers row. Click OK.




Click List Sales Persons then select Customers from Add drop down list.



Select Rows Layout under List Customers node, save all changes.






Run the application and notice that all customers are listed regardless to what Sales Person you select. Next step we will connect Customers list to select Sales Person.







6- Connect Sales Persons List with related Customers

Query Parameter and Parameter Binding will come to the rescue of relating entities in the screens that have data items without referential integrity.
Click Edit Query link beside Customers Data Item (Left Panel)

 
 




In Parameter section type SalesPersonParam, then from Filter section select Where, Salesperson_code, = and from the drop down select Parameter and the in the last drop down list select SalesPersonParam.



Save all changes and re-open BrowseSalesPersons screen. Expand Query Parameters node under Customers data item and click on SalesPersonParam. In the properties window click on Parameter Binding field and select SalesPersons from the drop down list.





After selecting SalesPersons type .selectedItem.Code (intellisense works here), so you should end up having SalesPersons.selectedItem.Code value for Parameter Binding property.






Save all changes and run the application, click on different Sales Persons items and notice the filter working on underneath customers list.
 


We have completed Browsing Sales Person Customers Application, thanks for viewing the blow and I hope this blog has assist you in your research.











Friday, January 18, 2013


Part 2, step by step developing Navision objects.


Previous...
Integrating Visual Studio 2012 LightSwitch and Dynamics NAV OData (Part 1) 

 
1- Build Dynamics NAV 2013 objects
Create SalesPersons Query object to include Customers count attribute:

From NAV Object Designer click on Query button, then click new button.
Enter Salesperson/Purchase in first DataItem Date Source Column, next DataItem Row enter Code & Name Columns.





 


Add New DataItem under Name Column and pick (or type) Customer in Data Source Table, then add another column under Customer DataItem but don't pick DataSource for this column, in Method Type pick Totals and in Method pick Count and change Name field to Customers.



Select DataItem Customer and View menu, Properties command (or Shift+F4) to bring the properties dialogue box. Set DataItemLink as shown below.




Click OK button and X out Customer - Properties window.





Save the Query with ID = 50010 and Name = wsSalesPerson

Now we are going to create Customer Page and expose the fields we want in it. You may use existing Customer List page (ID = 22), but its better practice to create a new page so we don't have to expose all the fields in Customer List Page.

The reason we will be using a page object to expose to customer data is to enable Customer edit in the future (not covered in this blog), as you used Query object then you will have only read only ability.
Start a new page, pick Customer for Table field and List for wizard type, and then click OK.



Select the desired fields from Available fields list and add to Field order List, No. and Sales Person Code must be selected for our example to work.


Click Finish button, and Save the page with ID= 50010 and Name = wsCustomerList.






2- Expose NAV objects as web services

Launch NAV RTC client, click on Departments, Administration, IT Administration, General, and web services link.

 

Click New and add Query and Page objects with ID 50010 and Name as shown below. Don't forget you need to check Publish check box.



Click ok.



Now we have completed the MS Dynamics NAV 2013 steps (Part 2), part 3 will cover Visual Studio 2012 LightSwitch HTML Client part.

Next...
Step by step developing Visual Studio 2012 LightSwitch application (Part 3)

Part 1, Integrating Visual Studio 2012 LightSwitch and Dynamics NAV OData.

OData is on of new exciting features Microsoft has added to MS Dynamics NAV 2013, which has a good impact on simplifying NAV integration.
Many good blogs and articles are out there that address Dynamics NAV OData feature consumed by Excel and SQL Server Reporting Services (SSRS); where in this blog we are going to use Visual Studio LightSwitch HTML Client which simplifies rapid client applications development, a tool can be used by information workers and developers to deliver proof of concept applications or even a full fledge application startups.
Another key point in this blog is to show you how to connect related entities from Dynamics NAV in LightSwitch using Query Parameter and Parameter Binding property which is not straight forward as it is when consuming relational databases data with referential integrity.

Visual Studio 2012 LightSwitch HTML Client

LightSwitch Silverlight Client application type was included in Visual Studio 2012 release, but later on Microsoft released LightSwitch HTML Client. Visual Studio LightSwitch Team Blog http://blogs.msdn.com/b/lightswitch/ is a good starting point to install and read more about LightSwitch.

Browsing Sales Person Customers Application

We will start by looking what we are trying to accomplish here and that is to build  HTML client application to assist sales persons to browse their customers of course that data all is coming straight from Navision database.

This application also serves a good starting point to build Windows 8 application that can run on Windows desktops, tablet pcs and Windows phones.
Below is a screen shot of the application we are going to build





Development Steps Summary:

Below steps are covered in details in part 2 of this blog which is Navision part.


1- Build Dynamics NAV 2013 objects.

2- Expose NAV objects as web services.

Below steps are covered in details in part 3 of this blog which is Visual Studio 2012 LightSwitch Html Client .


3- Build Visual Studio 2012 LightSwitch Html Client application.

4- Add NAV OData to LightSwitch application.

5- Build Sales Persons & Customers browsing screen.
6- Connect Sales Persons List with related Customers.

Next...
Step by step developing Dynamics NAV objects (Part 2)