Reputation: 207
I am trying to setup a form with table report and use REST sources only.
Currently I have a Form and Interactive report setup. It uses a rest source with dynamic items. i.e:
http://source/asm/instances/:group
where :group
is then searchable from the form.
Now the columns returned are all user related, but one item I want to be able to set via the REST API. So assuming I entered a group and get the following results:
group | name | surname | status
ABC | Dan | Murray | inactive
ABC | Mary | Swanson | active
The REST Source has a function to activate/deactivate the status
remotely on the tool. i.e
http://source/asm/instances/ABC/dan/activate
and
http://source/asm/instances/ABC/dan/deactivate
Now I need to modify the status column to be in a list form with two options, activate/deactivate. This is where the issue comes in. When either of the two items are selected, it needs to use the relevant REST source as posted above and post to the tool, meaning it will activate/deactivate on the fly. I have spent the entire weekend searching and trying and I just cannot find a way to do this.
The closest I got so far was to create a link, but that just routes me to the URL which is not what I need.
I really hope someone is able to help me here as I am struggling big time.
Upvotes: 0
Views: 1672
Reputation: 1760
Maybe I solved your problem, give it a try. :)
Oracle Application Express 20.2.0.00.20
I suppose you know how to set the REST Data Source (DS) and create an Interactive report with the data fetched from de DS, so I will skip those steps.
select
/*leave all the columns fetched from the DS*/
--
-- Add this column
'<a class="rest-button-status" data-id="'||<PRIMARY-KEY>||'">Link</a>' BUTTON
from #APEX$SOURCE_DATA#
Go to the BUTTON column definition, under Security disable Escape special characters.
Add a new hidden item and call it P1_NEW.
Run the application and you should see your Interactive Report with a link in the last column.
Now add an Dynamic action defined as (name it however you want):
// copy paste code
$(this.triggeringElement).attr('data-id')
EDIT Page Items to submit - P1_NEW
-- code
DECLARE
l_clob CLOB;
-- I added a parameter PK
v_url VARCHAR2(2000) := 'http://xxxxx:8080/ords/xxxx/xxxxxx/test-apex/deactivate?PK=';
BEGIN
L_CLOB := APEX_WEB_SERVICE.MAKE_REST_REQUEST(
-- I added a parameter PK
p_url => v_url||:P1_NEW,
p_http_method => 'POST' -- or GET or other
);
END;
The toggling system (activate/deactivate) is up to you, maybe the best solution is to have one endpoint and then the DS controls the status.
EDIT - based on comments Here are some screenshot of the second DA:
Execute Server-side Code
or Execute PL/SQL Code
(the name of the action depends on the Oracle APEX version you have)Upvotes: 0