Finally getting around to putting together the bits for my exploration into web services, and more importantly how to consume them using C#.
So what's the plan? Well first I need to create a very simple NAV app. Once this is done we need to create the new page objects before we can expose the relevant objects as web services. Finally we will move onto consuming the web services. This final step cuts write to heart of what my blog is going to chronicle – the journey through my initial learning on C# and how it will interact with NAV in the first instance, before becoming the language which will all need to code in (if the current roadmap is anything to go by!).
So to the very simple application itself. I am simply going to record some data each time I fill up my car with petrol. This is a typical and simple application of which there are hundreds about (not necessarily in NAV), but at least let's keep the concept simple in the beginning. The idea is to setup a Vehicle record, and then to record Fuel Entries each time I refuel. The following are the structures:
Average Cost per Litre
Fuel Entry Table
Cost per Litre (£)
Total Cost (£)
In order to investigate the exposure of codeunits as web services I have also create the following codeunit:
Fuel Mgmt. Codeunit
CalculateMPG(MilesParam : Decimal;LitresParam : Decimal) MPG : Decimal
IF LitresParam <> 0 THEN
MPG := MilesParam / (LitresParam * 0.22);
CalculateTotalCost(CostperLitreParam : Decimal;LitresParam : Decimal) TotalPoundCost : Decimal
TotalPoundCost := (CostperLitreParam * LitresParam);
The two functions in this codeunit are called on the validate triggers of the respective fields in the Vehicle table.
To round things off I have created 3 simple forms (which should be self explanatory):
As I say, nothing very special about this application from a NAV point of view, but we have to start somewhere.
Next time.... creating the pages to represent the forms. That should expose us to the TIF editor and transformation tool – I have used these a few times already with varied results so hopefully we can look at how these tools may be used.
Thank you for your post. Very helpfull - can't wait to see the next post.