Search code examples
javascriptrefreshoracle-apex

How to wait on a refresh of a classic report region before checking the length of the report?


Im using 18.2.0.00.12 , the default oracle apex client they provide for free.

My issue is that my classic report region is refreshing after I make a dynamic check for the length of the report.
My main page is a classic report with a list of values. There is a button to add a value in a modal dialog. After the element is added in the modal, the modal closes and a dynamic action is triggered on my main page to refresh the report (this is working). My issue is that after I refresh the report, I make another Javascript call (see below) in order to check the length of the report. Based on the result, it either shows/hides a button.

if ($('#report_RC_ATTACH').length > 0) 
{
$('#DELETE_ATTACH').show(); 
} else 
{
$('#DELETE_ATTACH').hide(); 
}  

The Static ID for my region is RC_ATTACH. The static region for my button is DELETE_ATTACH. Also note, after the dynamic action finishes, I am able to go into the console, put in the code above and the button show/hides correctly. I think the issue is that the region is refreshed after the code above is called.

My question: Is there a way to delay or wait until the refresh occurs before making the length check?

Let me know if I can provide anymore information.

Thanks,


Solution

  • On a classic report you need to wait for the apexafterrefresh event to trigger. You can create a dynamic action with the framework event After Refresh that waits for this event and place your code there. Refer to the documentation About Dynamic Action Events for details.