admin管理员组文章数量:1319463
How can we call javascript code from a PLSQL code in dynamic action of Oracle apex. Actually, my requirement is to select a Role(P2_ROLE) from a dropdown list. And than find all the usernames attached to this role using sql query. Once the usernamess are retrieved, all the rows in interactive grid should get coloured for these list of users. The IG contains a column name USER_NAME.
If The role is present in the IG, than I can make it work by writing the below code in dynamic action ---> Javascript code
$(document).ready(function() {
$("td:nth-child(28)").each(function() {
if ($(this).text() === apex.item( P2_ROLE ).getValue()) {
$(this).parent().children().css({'background-color': '#FF9999'});
}
});
});
But the issue is the Role that is picked up is not displayed in the interactive grid.
So as a workaround, I want to fetch all the usernames specific to that role using PLSQL and match them with the USER_NAME column in interactive grid using JAVASCRIPT.
But I am not sure how can I call JAVSCRIPT code in a PLSQL code. Basically I want to do something like this :
DECLARE
Cursor c_user_name is
select distinct user_name from wf_user_roles where role_name = :P2_ROLE;
l_USER_NAME varchar2(1000);
BEGIN
OPEN C_USER_NAME ;
LOOP
FETCH C_USER_NAME into l_USER_NAME;
EXIT WHEN C_USER_NAME%NOTFOUND;
-- Call this JAVASCRIPT code now
/*
$(document).ready(function() {
$("td:nth-child(28)").each(function() {
if ($(this).text() === l_USER_NAME) {
$(this).parent().children().css({'background-color': '#FF9999'});
}
});
});
*/
END LOOP;
END;
Can somebody please help me regarding this.
How can we call javascript code from a PLSQL code in dynamic action of Oracle apex. Actually, my requirement is to select a Role(P2_ROLE) from a dropdown list. And than find all the usernames attached to this role using sql query. Once the usernamess are retrieved, all the rows in interactive grid should get coloured for these list of users. The IG contains a column name USER_NAME.
If The role is present in the IG, than I can make it work by writing the below code in dynamic action ---> Javascript code
$(document).ready(function() {
$("td:nth-child(28)").each(function() {
if ($(this).text() === apex.item( P2_ROLE ).getValue()) {
$(this).parent().children().css({'background-color': '#FF9999'});
}
});
});
But the issue is the Role that is picked up is not displayed in the interactive grid.
So as a workaround, I want to fetch all the usernames specific to that role using PLSQL and match them with the USER_NAME column in interactive grid using JAVASCRIPT.
But I am not sure how can I call JAVSCRIPT code in a PLSQL code. Basically I want to do something like this :
DECLARE
Cursor c_user_name is
select distinct user_name from wf_user_roles where role_name = :P2_ROLE;
l_USER_NAME varchar2(1000);
BEGIN
OPEN C_USER_NAME ;
LOOP
FETCH C_USER_NAME into l_USER_NAME;
EXIT WHEN C_USER_NAME%NOTFOUND;
-- Call this JAVASCRIPT code now
/*
$(document).ready(function() {
$("td:nth-child(28)").each(function() {
if ($(this).text() === l_USER_NAME) {
$(this).parent().children().css({'background-color': '#FF9999'});
}
});
});
*/
END LOOP;
END;
Can somebody please help me regarding this.
Share Improve this question asked Oct 3, 2018 at 11:37 AbhaAbha 3473 gold badges12 silver badges31 bronze badges 1- related question: stackoverflow./questions/52613246/… – romeuBraga Commented Oct 3, 2018 at 20:19
1 Answer
Reset to default 4You can use apex.server.process:
https://docs.oracle./cd/E71588_01/AEAPI/apex-server-namespace.htm#AEAPI30050
With this function you can call a PL/SQL process with javascript and do something after this code return something.
Example: https://munity.oracle./thread/4094475
UPD.
JAVASCRIPT
apex.server.process("new_assign_roles",
{ x01: 'a_value', x02: 'b_value', x03: 'c_value' },
{
success: function(pData) {
//you can do anything here
console.log(pData);
apex.message.alert(pData.v_result);
}
}
);
ON DEMAND PROCESS
DECLARE
p_a VARCHAR2(1000) := APEX_APPLICATION.g_x01;
p_b VARCHAR2(1000) := APEX_APPLICATION.g_x02;
p_c VARCHAR2(1000) := APEX_APPLICATION.g_x03;
v_result VARCHAR2(4000) := p_a||' - '||p_b||' - '|| p_c;
BEGIN
-- you can do anything here
apex_json.open_object;
apex_json.write('success', true);
apex_json.write('v_result', v_result);
apex_json.close_object;
END;
You can see this example here:
https://apex.oracle./pls/apex/f?p=145797:33
login with:
workspace: stackquestions
user: user_test
pwd: stackquestions
application: 145797
page: 33
20191125AL > User user_test is locked.
本文标签: How to call Javascript from inside a PLSQL code in dynamic action of oracle apexStack Overflow
版权声明:本文标题:How to call Javascript from inside a PLSQL code in dynamic action of oracle apex - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742061269a2418601.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论