![]() |
#1 |
Участник
|
There is a number of posts and articles that show what you can really achieve with Client Extensibility in NAV 2009 SP1. This post goes the exact opposite way, to show the simplest possible example of a Client Extensibility add-in which includes callbacks between RTC and the Add-In, both ways:
In Visual Studio, add references to Microsoft.Dynamics.Framework.UI.Extensibility, System.Windows.Forms and (just to add colours) System.Drawing. To add the first one, browse for "Microsoft.Dynamics.Framework.UI.Extensibility.dll" which is in the RTC folder. The other references used here are both under ".NET": [url="http://blogs.msdn.com/blogfiles/nav/WindowsLiveWriter/SimpleClientExtensibilityexample_13E31/References_2.jpg"] ![]() } [/size]// No other code is needed to create the add-in, // But if you also want to exchange data between the add-in and NAV, then continue // Receive data from NAV publicoverridestring Value { get { returnbase.Value; } set { if (Convert.ToString(value) != "") { ((Button)this.Control).Text = Convert.ToString(value); } } } // Run NAV trigger OnControlAddIn privatevoid OnButtonClick(object sender, System.EventArgs e) { this.RaiseControlAddInEvent(1, "Button"); } } } Finally build the project. Copy your new dll and pdb file into the add-ins sub folder of RTC. Use the syntax sn -T [MyNewDll] from a Visual Studio command prompt to get the Public key token from your new dll. Register it in table 2000000069 "Client Add-in" with its name and Public key token, then add it to a page. To send data to the add-in, you also need to specify the "SourceExpr"-property. This can be either a variable or a field. In this case, it will just display the source expression on the button. For the purpose of keeping this post minimal, I won't go into any further details here, but I will mention one thing: I found that this line: if (Convert.ToString(value) != "") is important. It seems that some times, the page calls the add-in multiple times, and some times with a blank value. So if not testing that RTC has actually sent some data to the add-in, you may be overwriting with blank data, and you may spend time to work out why this part is not working. Lars Lohndorf-Larsen Microsoft Dynamics UK Microsoft Customer Service and Support (CSS) EMEA Источник: http://feedproxy.google.com/~r/Micro...y-example.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|