Create sales order from SQL

schoolkid
Member Posts: 103
Hi all,
i created a sales order Buffer table in NAV and on the ONINSERT() trigger i have written codes to insert the same data into Sales Header table , now i open SQL server and insert data into the SALES order Buffer table but the code written will not work and the insertion to sales header doesnt happen.
when i do the same in Cside Client it works .
i want to insert data into Sales orders form once it gets inserted in the Buffer table..
any help on this please
Thanks in advance
i created a sales order Buffer table in NAV and on the ONINSERT() trigger i have written codes to insert the same data into Sales Header table , now i open SQL server and insert data into the SALES order Buffer table but the code written will not work and the insertion to sales header doesnt happen.
when i do the same in Cside Client it works .
i want to insert data into Sales orders form once it gets inserted in the Buffer table..
any help on this please
Thanks in advance
0
Comments
-
SQL has no idea about the business logic (code) in NAV. You'll need to run some process from within a NAV client to use that.0
-
Hi,
beware that the OnInsert trigger is only executed if you do an Record.INSERT(TRUE) from within Navision
It is not executed because you insert a record in the table in SQL from outside Navision.
To be able to do that is a completely different and difficult process.
Regards,
WillyFostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.0 -
thanks for the replies ..
Now i have a SalesTable in SQL and i want to push the Data into NAV ..
can u suggest me which is the best possible solution that i can do to insert the data into NAVISION
Thanks in Advance...0 -
The best solution is to insert into your temp table and then run a process from within NAV. That can be done manually, on a timer, through a NAS with job scheduler, etc.
There is a ton of business logic and data validation that goes into creating orders.0 -
Hi,
We have done something similar, for Freight amounts . We have several third party applications write to a view of our table. We have a SQL trigger on that table that inserts a message into a Message queue. This message is picked up by the NAS and it will add a sales line to an existing sales order that has the freight amount and package tracking number. But be careful, this is not an easy process!
Inserting a Sales Header record through the NAS could be a tricky thing to do. What are you going to do when the Customer is blocked or over the Credit limit? You cannot have "Confirm" messages or any kind of form opening when the code is executed through the NAS.
I would suggest that you create a process that is run periodically by a user to transfer the information from your temporary table to the real Sales tables. This is by far the easiest solution.
I hope this helps,
Regards,
WillyFostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.0 -
As outlined here there are many different approaches that you can take to get this data into NAV. If you are running in version 5.0 the Job Scheduler that comes with NAV out of the box is a useful tool to automate these kinds of tasks.'
I recently worked on a project that had some similar requirements only it was working with Purchase Documents. The staging table approach works well when integrating with external systems and if you write to some sort of inbound sales invoice table and then read records out of that with something like a process only report or a codeunit to generate the necessary sales invoices.
I would suggest that your process only report has the following features:
- is fault tolerant (i.e. when it processes 10 records and 8 of them work and 2 error out, customer blocked, customer does not exist it successfully creates 8 invoices and leaves 2 in the staging table)
- You will probably need to use the if codeunit.run syntax to make it fault tolerant
- can be run by a user or via NAS -> use the if GUI allowed to check and determine if you can accept input from a user or provide status messages about progress
- use a progress bar if the process will loop through a lot of data and will be run by a user (this will ensure they know the process is still running and don't think the NAV client has hung)
- invoke as much base NAV logic as possible so orders are properly created (i.e. validate fields instead of just updating their value)
- the less custom code that you have to write the easier it is to support and maintain the solution
One final suggestion when building an integration process like this - think about what you would manually do to build up an order from the data that is passed to NAV from the staging table and use that as a plan for what you are trying to build. I find these integration projects a lot simpler when you think of them as just automating a manual process.0 -
jlandeen wrote:One final suggestion when building an integration process like this - think about what you would manually do to build up an order from the data that is passed to NAV from the staging table and use that as a plan for what you are trying to build. I find these integration projects a lot simpler when you think of them as just automating a manual process.
=D>
actually this is how I tell all developers to think when they develop anything. Start by doing it all manually (even going to the tables and typing data in new fields if necessary) and once you can do it manually THEN start coding.
It great to see more people thinking like this, and I wish everyone would.David Singleton0 -
-
When I am with a customer and they start asking for some silly modification, I get them to show me how they would do it manually step by step. Taking screen shots along the way. In the end either they realize its a crazy requirement, OR I have a fully document work flow ready to give to a developer.David Singleton0
-
I find that it's also a very good way to minimize customization -> therefore the solution is more maintainable going forward.
Also if most of the task automation steps can be completed in a new codeunit or custom report then the base object, new code stays nice and modular and won't impact upgrades too much.0 -
Thank you all for your replies .i will work on the suggestions given by you and get this job done in a good way....0
-
schoolkid wrote:Thank you all for your replies .i will work on the suggestions given by you and get this job done in a good way....
=D>David Singleton0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions