Scheduling NAV tasks from SQL Server
You cannot call NAV code directly from outside the database, but you can create a .NET program that can be used by SQL to issue commands through a NAV web service. This recipe will show you exactly what to do.
How to do it...
Create a new SQL CLR project in Visual Studio. When creating this project you will have to add a reference to your NAV database.
Right-click on your project in Solution Explorer and add a new stored procedure named
NAVJobScheduler
.Add the following code to the project:
using System; using System.Net; using System.IO; using System.Xml; public partial class StoredProcedures { [Microsoft.SqlServer.Server.SqlProcedure] public static void NAVJobScheduler( string ObjectType, int ObjectID, string Login, string Password,string Domain,string WebServiceURL) { string Body = @"<soapenv:Envelope xmlns:soapenv= ""http://schemas.xmlsoap.org/soap/envelope/""xmlns:run= ""urn:microsoft-dynamics-schemas/codeunit/RunObject"">" + "<soapenv:Header...