Good month to everybody!
This is my problem: I have 2 different reports for a Sales Order and I would like to give the user the ability to choose which one of these should be printed for a specific Order, at runtime.
If I understood correctly, in the Report Selections I can specify which reports are to be run, but they are run sequentially, one after the other.
What I want is to be able to choose from a list.
Is this possible?
Thanx in advance,
Alx
0
Comments
This should be easy when you modify cu. 229.
In function PrintSalesHeader you can add
I have not tested it, maybe the setrecfilter does not workbut it is worth a try.
Thanx for the tip, but I tried it and, indeed, the SETRECFILTER does not work! Any other suggestons?
Alx
I've tested it and after a small modification it worked
New Code
I got the error
Please post your code if it still does not work
Bedankt!
When I try to print I get the Report Selection - Sales form with S.Quote as Usage and I can't select any other Usage.
Here is the code:
ReportSelection.SETFILTER("Report ID",'<>0');
ReportSelection.SETFILTER(Usage,'S.Blanket');
IF SalesHeader."Document Type" = SalesHeader."Document Type"::"Blanket Order" THEN
IF FORM.RUNMODAL("Report Selection - Sales", ReportSelection = ACTION::LookupOK THEN
ReportSelection.SETRECFILTER;
ReportSelection.FIND('-');
REPEAT
REPORT.RUNMODAL(ReportSelection."Report ID",TRUE,FALSE,SalesHeader)
UNTIL ReportSelection.NEXT = 0;
I ran this through the Debugger and from what I understand, ReportSelection only stores the record selected on the form, in other words it behaves like an OUT parameter. The filter I have set on ReportSelection before calling the form is NOT passed on to the form.
I tried to experiment with RUNMODAL(Form) and Form.SETTABLEVIEW but the documentation is not really helpful...
Any hints?
Alx
IF FORM.RUNMODAL(FORM::"Report Selection - Sales", ReportSelection) = ACTION::LookupOK THEN
instead of
IF FORM.RUNMODAL("Report Selection - Sales", ReportSelection = ACTION::LookupOK THEN
What I need is a way to pass a filter TO the form, as it seems that ReportSelection only returns a record FROM the form.
Looks like something got completely messed up.
Could you e-mail me the codeunit so I can have a look at the complete code?
You can also send a p.m.
I am affraid I cannot help only having fragmented bits of code.
Any Results for this Problem?
I'm have the same task, a customer need's different Invoices for his Customers throughout the world. In Chile for Example are other informations about customs needed as e.g. in China or even in Germany.... so it results in 20 different reports for invoice :shock:
how to choose....
Michael Schumacher
oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
The problem is solved.
For you I think it is best to add an field 'INVOICE CODE' to the customer card and the report selections.
This way, every customer can have his own report if nessesairy.
If you copy this to the sales document and sales Invoice you can filter on this field in codeunit 229.
(This should be standard Nav!) :!:
Yeah in the meantime I found the Problem from alx ;-)
pressing Ctrl-Shift-F7 releases the filter and you can change the selection in the header ....
But I think you're right with the invoices. As I remember, this form cannot be runmodal inside a transaction..... right :?:
I thought about this extra field earlier. But my boss wanted a possibility to choose. Now I have arguments to take him away from this idea
Michael Schumacher
oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
The problem was in the form, there was a setfilter in the onopenform. We've created a new form.
Right. But there is no transaction, so the form can be run modaly without problems.
You can have a form, just don't use the standard navision report selection form.
Hope this helps.
PS. I've solved the problem with alx via email. You can have a copy if you want.
ok, that is good to know, maybe I mixed up some informations
YESSSSSIR! This would help! E-Mail is on the way so you can answer to it ;-)
Michael Schumacher
oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
Maybe I will mail it to Luc to, for the download section.
I put this in the printreport() function but it's still inside transaction.
Has anybody an idea where and how this selection can be made before transaction starts? I'm not sure where this begins
What I know is that I have to store the filter in a variable until it is needed.
Michael Schumacher
oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
Is it german functionality or is it customisation. It works fine in W1 and NL database?
Do you get the classic form.runmodal message?
standard german installation with this little lines for choosing report added
This was the first one I ever saw, it's the epos of what you can't do inside a transaction with the first thing is the runmodal... ;-)
so I think it's the standard.
in procedure run() first salespost(record) and then the print routines are invoked and then the commit :-(
I do not want to place this commit before printing, because if there goes anything wrong you can't print again because there is no more invoice.
Michael Schumacher
oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
If I understand right you have put a form.runmodal in the function Printreport of Codeunit 82.
Before this funtion is called navision uses a trick to get the right shipment/invoice via the last posting no.
Before this is done a COMMIT is raised in Codeunit 80.
Unfortunately the trick done by navision causes the database/table to be locked again.
There can be a few solutions for this.
One solution is to place a COMMIT in function PrintReport, this sould not be a problem because it was already raised in Codeunit 80.
An other problem is to replace the SalesShptHeader and SalesInvHeader by temporary varaibles. This does the same trick to get the right filter but does not lock the table. I think Navision should have done this to
Succes.
Ooops I didn't see that. Otherwise I wouldn't have asked ;-)
Yeah, I thought it commits after printing, so that if print goes wrong, the complete transaction will be rolled back.
And it seems to be just this way, because when this form.runmodal message comes, the invoice is still there..... if I didn't turn numbers in my head......
I have to try a little and think it over...
Thanks for the hints.
Michael Schumacher
oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
Table Report Selections has one more field from Greek Localization.
You have to insert to No. Series with a sequence number, and the same No. Series with the next sequence number. So when you print this kind of report you are going to have two print-outs.
(propably this change was made for the reason you want it!)
Regards Elias
Here's one tweek that you could make to make it a little more graceful when users escape. The standard look and feel would be that no reports print instead of all printing. If you changed things slightly, it would be this way.
Current Version:
IF ReportSelection.COUNT > 1 THEN
IF FORM.RUNMODAL(FORM::"Report Selection", ReportSelection) = ACTION::LookupOK THEN
// If user cancels all reports are printed !!!
ReportSelection.SETRECFILTER;
//* End Change <<<
ReportSelection.FIND('-');
REPEAT
Tweeked Version:
IF ReportSelection.COUNT > 1 THEN
IF FORM.RUNMODAL(FORM::"Report Selection", ReportSelection) = ACTION::LookupOK THEN
ReportSelection.SETRECFILTER
ELSE // Tweek
ReportSelection.Setfilter("Report ID",0); // Tweek
//* End Change <<<
IF ReportSelection.FIND('-') then // Tweek
REPEAT