Monday, March 26, 2012

Copy Responsibilities of a USER

Using the below script you can assign all the responsibilities of A user to B user. Change the user names before executing.


DECLARE
l_user_id NUMBER;
CURSOR cur_rec
IS
SELECT *
FROM fnd_responsibility_vl
WHERE responsibility_name in (SELECT frt.RESPONSIBILITY_NAME
FROM
fnd_user_resp_groups furg,
FND_RESPONSIBILITY fr,
fnd_responsibility_tl frt,
fnd_user fu
WHERE fu.user_id = furg.user_id
AND furg.responsibility_id = fr.RESPONSIBILITY_ID
AND frt.responsibility_id = fr.RESPONSIBILITY_ID
and fu.user_name='USER-A');
BEGIN
SELECT user_id
INTO l_user_id
FROM fnd_user
WHERE user_name = 'USER-B';
FOR rec_cur IN cur_rec
LOOP
fnd_user_resp_groups_api.insert_assignment
(user_id => l_user_id,
responsibility_id => rec_cur.responsibility_id,
responsibility_application_id => rec_cur.application_id,
security_group_id => 0,
start_date => SYSDATE - 1,
end_date => NULL,
description => NULL
);
COMMIT;
END LOOP;
END;
/

No comments:

Post a Comment