By default IR region allows to either enable Download button to all users or disable Download button to all users. Suppose if there is a requirement to enable/disable download button based on user role, then we need to go for customization.
Lets see how to achieve from the following steps,
Step 1 : Create an Authorization scheme to validate the user role returning Boolean type,
Shared Components → Security → Authorization Schemes → Create
Name : GET_USER_ROLE
Type : PL/SQL Function Returning Boolean.
Code:
CREATE OR REPLACE FUNCTION HAS_ROLES (
PROLE IN VARCHAR2
) RETURN BOOLEAN IS
ROLE_DETAILS ROLES%ROWTYPE;
BEGIN
SELECT *
INTO ROLE_DETAILS
FROM ROLES
WHERE ROLE = PROLE;
IF
ROLE_DETAILS.ROLE = ‘ADMIN’
THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END;
Step 2 : Assign a Static ID to interactive report,
Step 3 : Create a Dynamic action,
Event :- Click
Selection Type :- jQuery Selector
jQuery Selector :- #STATIC_REPORT_ID_actions_button
Security → Authorization Scheme :- GET_USER_ROLE
Action :- Execute Javascript Code
Code :-
setTimeout(function(){
$( “.icon-irr-download” ).parent().parent().parent().parent().prev().remove();
$( “.icon-irr-download” ).parent().parent().parent().parent().remove();
}, 100);