1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Calling apex.server.process

Discussion in 'Oracle Application Express (APEX)' started by sneha.bharti, Jun 7, 2017.

  1. sneha.bharti

    sneha.bharti Active Member

    Messages:
    45
    Likes Received:
    1
    Trophy Points:
    90
    Location:
    Lagos
    Hi All,

    I have an urgent requirement of using apex.server.process to call a dynamic action trigger , I am using it for getting asynchronous process.I am very new to javascripts, Please help me how to pass parameters in that.

    Your help will be highly appreciated.

    Thanks,
    Sneha Bharti
     
  2. Steven S.

    Steven S. Premium Member

    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    20
    Location:
    USA
    Dynamic Actions aren't called by name but by responding to an event such as a value being changed, a button click, etc. The apex.server.process is javascript that is usually invoked by a dynamic action that responded to an event.

    Getting to the part you asked about specifically which was how to pass values from the ajax. The apex.server.process invokes an AJAX callback. The AJAX callback is simply a PL/SQL function. This usually involves passing parameters values from the apex.server.process (javascript) to the AJAX callback (PL/SQL). There are several ways to do this and easily Googled

    This is some basic javascript which could be in a dynamic action , true action using execute javascript code. The dynamic action is activated by some event which in turn runs the true action shown below. This javascript calls the AJAX callback which is named START_CHANGE and passes the values assigned to the global parameters x01 and x02. These parameters can be referenced using global variables from the apex_application API. The values are passed to the AJAX callback function and they are used as needed. When that processing is complete, pData is returned and can be used to signal success or failure of the process and is displayed to the user through the console.log. In the example below is used only by the success function as the failure function option is not used.

    apex.server.process("START_CHANGE",
    { // pData
    x01 : $(this.triggeringElement).val() -- Item value coming from the event which triggered the dynamic action
    ,x02 : $('#P86_MS_ID').val() -- The value here comes from a page item which is returned using a jQuery reference.
    }
    { // pOptions
    dataType:"text"
    ,success:function(pData){
    console.log('Return:'+pData);
    }
    }
    );

    My response is very late since I joined tonight but hope this brief example can help others as well.
     
    Sadik likes this.