NAV Test Framework / Open/Close Sales Statistics from Sales Quotes

MACL2
Member Posts: 10
Hi,
I Need to write a patch that does the following:
Loop through all the sales quotes. For each sales Quote the sales statistics Action has to be launched (there is some code on page 160 that is executed). Then just Close sales statistics page again and proceed to the next sales Quote.
To do it the traditional way I could write a Report/codeunit that Loops through the sales quotes. Since I cannot have any GUI interaction (page 160 opens when I launch the action Sales statistics) I would copy the code from page 160 and integrate it into my Report/codeunit.
So I thought of another Approach. Why not use the test Framework that NAV provides where I can handle UI interactions. I wrote a simple test codeunit und tried to achieve the above mentioned Goal. Here is the code:
OBJECT Codeunit 99992 Test: Open Statistics Page
{
OBJECT-PROPERTIES
{
Date=15.11.17;
Time=11:50:22;
Modified=Yes;
Version List=;
}
PROPERTIES
{
Subtype=Test;
OnRun=BEGIN
END;
}
CODE
{
VAR
SalesHeader@1000000000 : Record 36;
SalesStatistics@1000000002 : TestPage 160;
SalesQuotes@1000000003 : TestPage 9300;
[Test]
[HandlerFunctions(SalesStatisticsPageHandler)]
PROCEDURE MyTestFunction@1000000001();
BEGIN
// Quotes
SalesHeader.SETRANGE("Document Type", SalesHeader."Document Type"::Quote);
SalesQuotes.OPENEDIT;
IF SalesHeader.FINDSET THEN REPEAT
SalesQuotes.GOTORECORD(SalesHeader);
SalesStatistics.TRAP;
SalesQuotes.Statistics.INVOKE;
UNTIL SalesHeader.NEXT = 0;
SalesQuotes.CLOSE;
END;
[ModalPageHandler]
LOCAL PROCEDURE SalesStatisticsPageHandler@1000000000(VAR SalesStatistics@1000000000 : TestPage 160);
BEGIN
SalesStatistics.OK.INVOKE;
END;
BEGIN
END.
}
}
This is actually the first time I am using the test Framework. My Problem is that page 160 (sales statistics) is opened physically instead of using the ModalPageHandler I have provided. Somewhere I am missing something.
One more thing: In my case the test function should of course commit the changes to the database! Some VAT relevant fields are updated.
It would be great if someone could help me to get the above code to work.
Best regards,
MACL2
I Need to write a patch that does the following:
Loop through all the sales quotes. For each sales Quote the sales statistics Action has to be launched (there is some code on page 160 that is executed). Then just Close sales statistics page again and proceed to the next sales Quote.
To do it the traditional way I could write a Report/codeunit that Loops through the sales quotes. Since I cannot have any GUI interaction (page 160 opens when I launch the action Sales statistics) I would copy the code from page 160 and integrate it into my Report/codeunit.
So I thought of another Approach. Why not use the test Framework that NAV provides where I can handle UI interactions. I wrote a simple test codeunit und tried to achieve the above mentioned Goal. Here is the code:
OBJECT Codeunit 99992 Test: Open Statistics Page
{
OBJECT-PROPERTIES
{
Date=15.11.17;
Time=11:50:22;
Modified=Yes;
Version List=;
}
PROPERTIES
{
Subtype=Test;
OnRun=BEGIN
END;
}
CODE
{
VAR
SalesHeader@1000000000 : Record 36;
SalesStatistics@1000000002 : TestPage 160;
SalesQuotes@1000000003 : TestPage 9300;
[Test]
[HandlerFunctions(SalesStatisticsPageHandler)]
PROCEDURE MyTestFunction@1000000001();
BEGIN
// Quotes
SalesHeader.SETRANGE("Document Type", SalesHeader."Document Type"::Quote);
SalesQuotes.OPENEDIT;
IF SalesHeader.FINDSET THEN REPEAT
SalesQuotes.GOTORECORD(SalesHeader);
SalesStatistics.TRAP;
SalesQuotes.Statistics.INVOKE;
UNTIL SalesHeader.NEXT = 0;
SalesQuotes.CLOSE;
END;
[ModalPageHandler]
LOCAL PROCEDURE SalesStatisticsPageHandler@1000000000(VAR SalesStatistics@1000000000 : TestPage 160);
BEGIN
SalesStatistics.OK.INVOKE;
END;
BEGIN
END.
}
}
This is actually the first time I am using the test Framework. My Problem is that page 160 (sales statistics) is opened physically instead of using the ModalPageHandler I have provided. Somewhere I am missing something.
One more thing: In my case the test function should of course commit the changes to the database! Some VAT relevant fields are updated.
It would be great if someone could help me to get the above code to work.
Best regards,
MACL2
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