Need to produce 2 files where 1 files reads the other
engsiong75
Member Posts: 143
Hi
I have a customization that print a report in pdf and saves it to a folder . This program is working fine. I tried to modify the report so that the pdf file is first produced and then it is read by a second program and a text file is created in the same folder.
The problem is that I cannot get the pdf file to be printed within the same report as the one trying to access the pdf file. The pdf file is only produced after the program is completed.
1) I have tried using commit statements.
2) I tried to get other reports or codeunits to fire but they do not work.
The only way I could get it to work was when the debugger was on.
Any suggestions?
Tan Eng Siong
I have a customization that print a report in pdf and saves it to a folder . This program is working fine. I tried to modify the report so that the pdf file is first produced and then it is read by a second program and a text file is created in the same folder.
The problem is that I cannot get the pdf file to be printed within the same report as the one trying to access the pdf file. The pdf file is only produced after the program is completed.
1) I have tried using commit statements.
2) I tried to get other reports or codeunits to fire but they do not work.
The only way I could get it to work was when the debugger was on.
Any suggestions?
Tan Eng Siong
0
Comments
-
how do u read data from the pdf file???0
-
I am using an API to handle that.0
-
Sorry. Let me clarify. The logic to produce the pdf file into a folder is using an API. The logic is read the pdf file is using a third party tool.0
-
you could make a loop that refreshes the folder where the pdf is stored and let it loop until the files has been found (or a timeout of x) and when the file is found you can do your magic.0
-
Yeah, it's usually not that the program has to end for the file to be created, it's just that there's a delay. Typically only a few seconds. Using the debugger and stepping through the code probably took at least that many seconds, so it looked like the debugger made it work.
As Belias suggested, I would try using the SLEEP command. Look into EXISTS as well. You can look for the file, if you don't find it sleep for a few seconds, then look again. If you can't find it after a few attempts then throw an error.0 -
The SLEEP(3000) does not work if I am trying to get the report to produce the pdf file and then trying to read it in the same report. I tried SLEEP(30000) but it also does not work. Any other better ideas? I also tried it with commit statements but it does not execute.0
-
The actual saving of the file is not up to Navision. That's Windows code and whatever thread needs to execute for the file system to recognize the new file is probably not running.
Belias' runmodal v. run idea is a good one. RUNMODAL should technically hog the CPU and not let anything else happen until it is done. By using RUN instead (if you're not) it should allow the OS to schedule the threads and the previous ideas like SLEEP should work.
I know that it is possible to create a file and then do something with it in the same report as I have PDFd reports and attached them to emails many times.0 -
"b" option: (if applicable)
wrap your report and your "3d party function" in a codeunit, and then run them sequentially
OnRun()Report.runmodal(blahblah); //this is ok because, you can let the report finish mythirdparty.mybrilliantfunction(myshiningpdffilepath);
0 -
>>did you try to put your code in Onpostreport trigger? (i think so)
Yes, I did.
>>Report.runmodal(blahblah); //this is ok because, you can let the report finish
You mean instead of launching the report from the report from itself, you want me to launch it from a codeunit?
I also have seen a feature that creates the pdf file and then attachs it to email. I will check if the developer what was done.0 -
Yes!engsiong75 wrote:You mean instead of launching the report from the report from itself, you want me to launch it from a codeunit?
I don't know what you want to do...if you want to send a pdf, you can use the method i just said!engsiong75 wrote:I also have seen a feature that creates the pdf file and then attachs it to email. I will check if the developer what was done.
1. run report on a pdf printer
2. attach the saved pdf to a mail0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 250 Dynamics CRM
- 102 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
