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.