bibiji
bibiji

Reputation: 167

How do i set dynamic default value of a rest data source in oracle apex?

I have just started learning oracle apex. I imported an external API into oracle apex(https://localhost/report/?dateFrom=2022-09-30&dateTo=2022-10-01) . This API has two parameters dateFrom and dateTo. I want to dynamically set the datefrom parameter to 5 days ago and dateTo to today in default value. How can I do this?

enter image description here

Upvotes: 1

Views: 1964

Answers (1)

Carsten
Carsten

Reputation: 1124

One option is to define the parameter value for the component, which is using the REST data source. If that is, for instance, a report, you can configure within the Parameters Node in Page Designer. In the tree on the left hand side, click the node for your parameter, and then (in the Attributes pane on the right, choose Expression or Function Body, and enter the expression to compu For a REST Synchronization (download data to local table), you would configure the same as a Synchronization Step.

These options will configure the dynamic value at the component level (the component which uses the REST Data Source).

However, your question reads like you're after a default to be applied to all components using that REST Data Source. The Expression or Function Body options are not available at the REST Source level. I'd see two approaches:

  • Define an application item (APP_REST_DATEFROM), and a Application Computation to set the value for this item. In the REST Source, then simply use &APP_REST_DATEFROM. as the value for your parameter. At the component level, it's important to switch the parameter value to REST Source Default.
  • Another option allows you to completely take these parameters out of the REST Source configuration, but implies some PL/SQL coding effort: You could author a REST Source Plug-In, where the Plug-In code implements custom handling for all aspects of the HTTP requests being made for the REST Data Source. That typically includes pagination, but can include all parameter handling (HTTP Header, URL Parameters, etc). An example for such a Plug-In is here: https://github.com/oracle/apex/tree/22.1/plugins/rest-source/fixed-page-size

I hope this helps.

Upvotes: 1

Related Questions