Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Apex 5.0 Set Value To Item using JavaScript

I built an interactive report based on View That Contains the master & details data, and I used Column Break To let the Report makes sense, and I used The master ID as a link to report that I built using FO Designer, so I used a hidden Item to set the ID value in it, and to print the report based on this value.

So I used a dynamic action to set the value from the record (using $s('P50_NEW',this.triggeringElement.id)). but the value didn't stored in the Item (The Session State), and I stuck here.

Please Can anyone help me how to do it please, and how to make apex to set the session state at first then print the report.

Thanks.

like image 284
Mahmoud Momani Avatar asked Sep 16 '15 09:09

Mahmoud Momani


2 Answers

As per the API Reference, the $s('P50_NEW',this,triggeringElementId) doesn't set the value in session state. The scope of $s(...) setting is for the current page, not for the session.

In order to set the value in session, you can invoke apex.server.process API to set the value in session.

So, the updated Javascript for Dynamic Execution will be like the following:

$s('P50_NEW',this.triggeringElement.id);
apex.server.process ( "SAVE_HIDDEN_VALUE_IN_SESSION_STATE", {
  x01: "set_session_state",
  pageItems: "#P50_NEW"
  }, {dataType: 'text'} );
like image 143
bprasanna Avatar answered Sep 19 '22 14:09

bprasanna


If you would need to set session state to use the value in a report SQL source, the simplest solution would be to specify the item name in the report Page Items to Submit attribute and refresh the report:

apex.item( "P50_NEW" ).setValue (this.triggeringElement.id);
apex.jQuery('#Report').trigger('apexrefresh');

(assuming that the report Static ID is Report)

like image 41
Valentine Nikitsky Avatar answered Sep 19 '22 14:09

Valentine Nikitsky