Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
UPDATE database record after/just before report closes
ashley.owens
<p><span>I have a requirement to make the details of a report visible if database field RPTEXEC==0. In addition, once the report is run, RPTEXEC must be updated to 1 so the next time the report is run, the details do not show.
The report updates the database & displays data correctly when shown in the web viewer, but when it's exported to PDF, the report seems to execute again & RPTEXEC now equals 1, so the details of the report are no longer visible.
I have tried putting the code that updates RPTEXEC in functions fetch, beforeClose, afterClose & close, but the database update is still occuring when the report is exported to PDF.
Any idea where to put code that updates the database so it fires AFTER the report is run? Thanks so much for your suggestions! </span></p>
Find more posts tagged with
Comments
kclark
<p>Do you have a runnable copy of the rptdesign you can attach?</p>
ashley.owens
<p>Thank you for your reply. I have attached the report. Please let me know if you need an explanation on any of its parts. Thanks again!
wwilliams
<p>It is my understanding that the report actually does run twice once for the web viewer and again for pdf, xls etc.. There is a way around it, but unfortunately this only works with parametrized reports.</p><p>it might be easier to change your update statement to something like;</p><p>UPDATE INVOICE SET RPTEXEC = (RPTEXEC + 1) WHERE RPTEXEC < 2 and " + params["where"]; //( ( invoice.invoiceid = 92632 ))</p><p> </p><p>or try a PGV/global variable, this seems to work with onRender on a detail table <span>if</span><span> </span><span>(</span><span>reportContext</span><span>.</span><span>getOutputFormat</span><span>()</span><span> </span><span>==</span><span> </span><span>"pdf"</span><span>){</span></p><p>set flag....</p><p>}</p><p>KClark should have a more definitive answer.</p>
ashley.owens
<p>Thank you for your reply! We decided to configure this report as "Direct Print" (and not Browser View). That way, the report only executes once.</p>
ashley.owens
<blockquote class="ipsBlockquote" data-author="wwilliams" data-cid="118272" data-time="1373461967"><div><p>It is my understanding that the report actually does run twice once for the web viewer and again for pdf, xls etc.. There is a way around it, but unfortunately this only works with parametrized reports.</p><p>it might be easier to change your update statement to something like;</p><p>UPDATE INVOICE SET RPTEXEC = (RPTEXEC + 1) WHERE RPTEXEC < 2 and " + params["where"]; //( ( invoice.invoiceid = 92632 ))</p><p> </p><p>or try a PGV/global variable, this seems to work with onRender on a detail table <span>if</span><span> </span><span>(</span><span>reportContext</span><span>.</span><span>getOutputFormat</span><span>()</span><span> </span><span>==</span><span> </span><span>"pdf"</span><span>){</span></p><p>set flag....</p><p>}</p><p>KClark should have a more definitive answer.</p></div></blockquote><p>Hi wwilliams! Can you explain how to do it with parametrized reports?</p>
ashley.owens
<p>I tried adding the "__format" parameter (setting it to "pdf"), and I also followed the example of an OOB Maximo report and put the SQL in beforeClose() with condition
if(reportContext.getOutputFormat() != "pdf")
I also tried setting reportContext.getOutputFormat() to a global variable in beforeFactory() and use that to determine whether SQL should be executed.
Unfortunately, the report SQL still executed a 2nd time when exporting (to PDF, for example).
Has anyone been able to successfully set a report to execute SQL only once, or to NOT execute SQL when it's exported?
Thank you so much for any advice!</p>