I have an external application writing data directly into the Nav tables via a stored procedure and unfortunately this is the only way to accomplish this.
I need to invoke some sort of action in Nav to start the business logic against the inserted records from the stored procedure.
for example if i run this stored procedure
INSERT INTO NAVDB$TestTable (name,inserted)
VALUES ('Kevin', '');
I would like to have the code below in nav on this TestTable's onInsert() function run.
inserted := 'some name was inserted from stored procedure';
my needs are deeper than this use, but once i get the onInsert() or something comparable to work I would be extremely happy.
Thanks
Comments
NAV business logic can only be executed from 'inside' NAV. Therefore, this code needs to be executed through NAV webservices or through the NAV Application Server.
I have seen examples of people calling nav webservices in Nav 2009 and using some SQL user defined CLR functions to invoke the webservice and some that use SQL jobs to invoke them.
http://mibuso.com/blogs/ara3n/2009/11/1 ... b-service/
What I cannot find is a more current example with Nav 2013 and Visual Studio 2012(this version of visual studio doesn't allow you to add a web reference at all in a SQL Server Database project)
I think it is possible to run a codeunit through a nav webservice called from a SQL record insert trigger using a SQL CLR User Defined Function.
so something like (SQL Code)
that will call the SQL CLR function named some_user_defined_function(params)(C# inside of a SQL Server Database Project)
I cannot seem to get a web reference attached to this to invoke it like i would in a normal C# project.
If anyone please has any ideas, I am being driven crazy trying to solve this problem. ](*,)
Thanks!!
That is possible, but that's something different then your first statement.
I've done exactly this for several clients and it works great.
I probably could have used NAS to periodically read the data and that would have been fine, but I wanted true real time data manipulation.
Below is my example.
I have DB_A that receives data often that needed to be sent when it is filled with data from a third party.
I have Nav_DB and a Nav_instance
I created a service in c# using Microsoft's SQL Dependency class to 'watch' for data changes in DB_A. When a record is inserted into DB_A I read the record that was written and send it no Nav_instance over webservices. I chose to use SQL Dependency over SQL CLR because of the simplicity and speed that SQL Dependency offers.
In my web services I insert the data that I sent and run a process to do something with that data.
The result is sub-second transactions from the time of the write into DB_A to when Nav processes the data.
Thank you all for your suggestions.