How to Create Sales Lines in Test CodeUnit

markcle
Member Posts: 65
Hi All
We're and end user developing some of our own extensions, so we can't use the test tool or test libraries. I need to write tests that insert lines (which will update other items based on an event subscription)
I got as far as opening the sales order in edit mode (hard-coding the sales order no for now), but I'm stuck on how to create a line item. Could anyone point me in the right direction. Here's my proc:
How would I go about inserting a sales line in this order and then getting the value form one of it's fields?
Thanks
Mark
We're and end user developing some of our own extensions, so we can't use the test tool or test libraries. I need to write tests that insert lines (which will update other items based on an event subscription)
I got as far as opening the sales order in edit mode (hard-coding the sales order no for now), but I'm stuck on how to create a line item. Could anyone point me in the right direction. Here's my proc:
[Test] procedure TestSalesOrderline() var SalesOrderCard: TestPage "Sales Order"; begin SalesOrderCard.OpenEdit(); with SalesOrderCard do begin GoToKey(1, 'S200020'); "No.".AssertEquals('S200020'); // Insert a line with item no 'FLOC' OK.Invoke(); end; end;
How would I go about inserting a sales line in this order and then getting the value form one of it's fields?
Thanks
Mark
0
Answers
-
Do you need to test specifically page behaviour?
Can you insert your lines on table level?0 -
I need to test subscriptions and the code units they run. For example, for certain freight types, when the line total changes (or new lines are added), i need to recalculate the total freight line (and update it) as it is based on a % of $0
-
which events are your subscriptions are based on? Table events or page events?0
-
These are the two I'm currently using:
[EventSubscriber(ObjectType::Table, Database::"Sales Line", 'OnAfterModifyEvent', '', true, true)] [EventSubscriber(ObjectType::Table, Database::"Sales Line", 'OnAfterInsertEvent', '', true, true)]
I am somewhat puzzled by OnAfterInsite, it triggers twice for every line when I just open a sales order in edit mode. No new lines have been inserted at all, but it still fires twice0 -
[Topic moved from 'NAV Tips & Tricks' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
These are the two I'm currently using:
[EventSubscriber(ObjectType::Table, Database::"Sales Line", 'OnAfterModifyEvent', '', true, true)] [EventSubscriber(ObjectType::Table, Database::"Sales Line", 'OnAfterInsertEvent', '', true, true)]
I am somewhat puzzled by OnAfterInsite, it triggers twice for every line when I just open a sales order in edit mode. No new lines have been inserted at all, but it still fires twice
It triggers several times because to calculate the totals, the Page inserts into (temporary) Sales Line table. To avoid that, the first thing your event should check, is if the record is "real" or temporary to avoid such situations.0
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