Inserting data in Navision tables
                
                    Dredijs                
                
                    Member Posts: 3                
            
                        
            
                    I Have a problem. We are building a webshop. How we can autpmated to put data in navision tables (Sales Header, sales laine, Items...) when client made order in webshop?
The Webshp is using another SQL database, so after order, system should import in table Item a product and update Sales Header andSales line table.
What kind of solution i need? ](*,)
                The Webshp is using another SQL database, so after order, system should import in table Item a product and update Sales Header andSales line table.
What kind of solution i need? ](*,)
0                
            Comments
- 
            You simply need NAS to periodicaly monitor the other db and create so. You or NSC has to create the codeunites.0
 - 
            Thank You.. Where i can find some codeunit samples?0
 - 
            For the NAS installation you should read the w1w1atas.pdf in the product cd.
Then you you should create a single instance codeunit and call it in the NASHandler funtion in codeunit 1 like:IF (COPYSTR(Parameter,1,9) = 'TEST') THEN MYCodeunit.RUN;in the REPEAT statement, just like the:IF (COPYSTR(Parameter,1,4) = 'ADCS') THEN BEGIN ...
In your codeunit you could query the other database for the data you want and then create the sales lines and headers...0 - 
            I forgot to mention that you should declare a variable of type Automation: 'Navision Timer 1.0'.Timer in your codeunit and in the OnRun trigger you should do something like that:
IF ISCLEAR(Timer) THEN BEGIN CREATE(Timer); Timer.Interval := 60000;//that is 1 minute in milliseconds Timer.Enabled(TRUE); END;
and set the timer interval to what ever time you want...
Then in the Timer::Tmer(Milliseconds:Integer) trigger that is created in your codeunit should add your code (or in functions that are called within that trigger)...
I hope you got the general view of a NAS implementation...0 - 
            Here is an example of single instance codeunit.
OBJECT Codeunit 50009 NAS Handler Timer { OBJECT-PROPERTIES { Date=10/09/06; Time=11:41:53 AM; Modified=Yes; Version List=TEC01.00; } PROPERTIES { SingleInstance=Yes; OnRun=BEGIN IF ISCLEAR(Timer) THEN CREATE(Timer); Timer.StartTimer(6000); IsRunning := TRUE; END; } CODE { VAR Timer@1004 : Automation "{DDADD7CC-AD56-4CA6-9C85-22AE76BF21A1} 3.0:{E7414D60-2D83-44C7-826A-FD14557299F0}:'CP Timer'.cTimer" WITHEVENTS; IsRunning@1005 : Boolean; JobScheduler@1000000002 : Codeunit 50010; PROCEDURE CodeUnitIsRunning@2() : Boolean; BEGIN EXIT(IsRunning); END; EVENT Timer@1004::TimerEvent@1(); BEGIN JobScheduler.RUN ; END; BEGIN END. } }
Here is the change in CU 1 in NASHandler function I'm using JOBSCHEDULER as my string parameter for NASEND; IF (COPYSTR(Parameter,1,4) = 'ADCS') THEN BEGIN IF STRPOS(Parameter,' ADCSID=') > 0 THEN IF EVALUATE(ADCSID,COPYSTR(Parameter,STRPOS(Parameter,'=') + 1)) THEN ADCSNASStartup.SetNASID(ADCSID) ELSE ADCSNASStartup.SetNASID('NAS1'); ADCSNASStartup.RUN; CGNASStartedinLoop := TRUE; END; //S001 Start IF (COPYSTR(Parameter,1,8) ='JOBSCHEDULER') THEN BEGIN CLEAR(T_MailTimer); T_MailTimer.RUN; CGNASStartedinLoop := TRUE; END; //S001 End IF (COPYSTR(Parameter,1,4) = 'NEP-') THEN BEGIN EPNASSetup.GET(Parameter); IF EPNASSetup."Front End Processing" THEN BEGIN EmployeePortalApplSrv.SetNASID(Parameter);
Here is example on how to create a sales Header. You have to put this in a Codeunit and maybe call it from single instance codeunit.CLEAR(SalesHeader); SalesHeader.VALIDATE("Document Type", SalesHeader."Document Type"::Order); SalesHeader.VALIDATE("No.",''); SalesHeader.INSERT(TRUE); SalesHeader.SetHideValidationDialog(TRUE); SalesHeader.VALIDATE("Sell-to Customer No.", Cust."No."); SalesHeader.VALIDATE("External Document No.", "Document No."); SalesHeader.VALIDATE("Order Date", "Order Date"); SalesHeader.VALIDATE("Document Date",WORKDATE); SalesHeader.VALIDATE("Salesperson Code","Salesperson Code"); SalesHeader.VALIDATE("Ship-to Name", COPYSTR("Ship Cust First Name" + ' ' + "Ship Cust Last Name",1,50) ); SalesHeader.VALIDATE("Ship-to Address", "Shipping Addr1"); SalesHeader.VALIDATE("Ship-to Address 2", "Shipping Addr2"); SalesHeader."Ship-to City" := "Shipping City"; SalesHeader."Ship-to County" := "Shipping State"; SalesHeader."Ship-to Post Code" := "Shipping Zip"; SalesHeader."Ship-to Country Code" := "Shipping Country"; SalesHeader.VALIDATE("Shipment Method Code", "Shipping Code"); SalesHeader.VALIDATE("Package Code", 'CUSTOM12X12X12'); SalesHeader."No. of Packages" := 1; SalesHeader."Authorization No." := "Authorization Num"; //SalesHeader.VALIDATE("Coupon/Promotion Code","Promo Code"); SalesHeader."Invoice Discount Calculation" := SalesHeader."Invoice Discount Calculation"::Amount; SalesHeader."Invoice Discount Value" := - "Discount Amt"; SalesHeader.MODIFY(TRUE);
And here is how to create a sales line.CLEAR(SalesLine); SalesLine."Document Type" := SalesHeader."Document Type"; SalesLine."Document No." := SalesHeader."No."; SalesLine."Line No." := PendingOrderslines."External Line No."; SalesLine.INSERT(TRUE); SalesLine.VALIDATE(Type,PendingOrderslines.type); SalesLine.VALIDATE("No.",PendingOrderslines."No."); SalesLine.VALIDATE(Quantity,PendingOrderslines.Quantity); SalesLine.VALIDATE("Unit of Measure Code", PendingOrderslines."Unit of Measure"); SalesLine.VALIDATE("Unit Price",PendingOrderslines.Amount); SalesLine.MODIFY(TRUE);0 - 
            That CP timer object is no longer part of NAV. I am pretty sure that we can simply copy the dll from 4.0 and register it to be used in a 5.0 SP1 tech upgrade. Can anyone confirm this, or do we need to modify the code to use a different timer?0
 - 
            Yes you can register the old cp timer. I've done it for a client and it works.
I suggest to use the CGTimer. It's the same thing but it comes std with 5.0 and 2009.0 - 
            
 
Categories
- All Categories
 - 73 General
 - 73 Announcements
 - 66.7K 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
 - 323 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
 


