Requirement
React to a Javascript call to apex.server.process
In my example, at the end I'll call an inline dialogue after processing.
Solution
Create a Javascript dynamic action. In my example it is initiated with a button.
Explanation
This defines and executes a procedure called "call_refresh".
It accepts and returns a variable which is displayed as an alert for demo purposes.
It demonstrates how code can be deliberately executed after waits, where to put code in case of error, where to put code on success, and even code that gets executed regardless of failure. In my case to open an inline modal dialog with static ID of STATIC1.
Here is the code for the application process called MY_CALLBACK.
v_parameter_in VARCHAR2(100);
v_result VARCHAR2(100);
BEGIN
v_parameter_in := :P_TEXT_IN;
SELECT v_parameter_in || '-COMPLETED'
INTO v_result
FROM DUAL;
apex_json.write('success', true);
apex_json.write('result', v_result);
apex_json.close_object;
EXCEPTION WHEN OTHERS
THEN
apex_json.open_object;
apex_json.write('success', false);
apex_json.write('result', SQLERRM);
apex_json.close_object;
END;
This shows how you would make use of incoming variables (although there ware other ways to pass variables to an application process). Play with the SQL to force errors and see how it behaves.
Comments
Post a Comment