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.











No comments:

Post a Comment