Showing posts with label HR Security Profiles. Show all posts
Showing posts with label HR Security Profiles. Show all posts

Friday, February 26, 2016

API to Attach Profile Options at Various Level

   CURSOR get_resp
   IS
      SELECT responsibility_id, application_id, responsibility_name
        FROM fnd_responsibility_tl
       WHERE responsibility_name = 'XXH AR Super User' AND language = 'US';

   CURSOR get_profile
   IS
      SELECT profile_option_name,
             user_profile_option_name,
             CASE
                WHEN user_profile_option_name = 'HR: Security Profile'
                THEN
                   '1062'
                WHEN user_profile_option_name = 'HR:Business Group'
                THEN
                   '81'
                WHEN user_profile_option_name = 'HR:User Type'
                THEN
                   'INT'
                WHEN user_profile_option_name = 'GL Ledger Name'
                THEN
                   'DHCI Ledger'
                WHEN user_profile_option_name = 'MO: Security Profile'
                THEN
                   '1062'
                WHEN user_profile_option_name = 'MO: Operating Unit'
                THEN
                   '101'
                WHEN user_profile_option_name = 'GL: Data Access Set'
                THEN
                   '1000'
             END
                profile_value
        FROM fnd_profile_options_vl
       WHERE user_profile_option_name IN
                ('HR: Security Profile',
                 'HR:Business Group',
                 'HR:User Type',
                 'GL Ledger Name',
                 'MO: Security Profile',
                 'MO: Operating Unit',
                 'GL: Data Access Set');

   l_return_status   BOOLEAN := FALSE;
BEGIN
   FOR i IN get_resp
   LOOP
      FOR j IN get_profile
      LOOP
         l_return_status := FALSE;

         l_return_status :=
            fnd_profile.save (x_name                 => j.profile_option_name,
                              x_value                => j.profile_value,
                              x_level_name           => 'RESP', --SITE, APPL, USER
                              x_level_value          => i.responsibility_id, -- Site ID, Application ID, User ID
                              x_level_value_app_id   => i.application_id -- Pass Null if not at Responsibility Level
);

         IF l_return_status
         THEN
            DBMS_OUTPUT.
             put_line (
                  j.user_profile_option_name
               || ' has been attached with value '
               || j.profile_value
               || ' for '
               || i.responsibility_name);
         ELSE
            DBMS_OUTPUT.
             put_line (
                  'Failure: '
               || j.user_profile_option_name
               || ' has not been attached with value '
               || j.profile_value
               || ' for '
               || i.responsibility_name);
         END IF;

         COMMIT;
      END LOOP;
   END LOOP;
END;

Monday, June 9, 2014

Query to Extract Profile Options Enabled at Site / Application / Responsibility / User Level's

Profile’s Enabled at Site Level

SELECT fpot.user_profile_option_name, fpov.profile_option_value
  FROM fnd_profile_option_values fpov,
       fnd_profile_options fpo,
       fnd_profile_options_tl fpot
 WHERE     fpo.profile_option_id = fpov.profile_option_id
       AND fpo.profile_option_name = fpot.profile_option_name
       AND fpot.language = 'US'
       AND fpov.level_id = 10001                              -- Site Level ID

Profile’s Enabled at Application Level

SELECT fat.application_name,
       fpot.user_profile_option_name,
       fpov.profile_option_value
  FROM fnd_profile_option_values fpov,
       fnd_profile_options fpo,
       fnd_profile_options_tl fpot,
       fnd_application_tl fat
 WHERE     fpo.profile_option_id = fpov.profile_option_id
       AND fpo.profile_option_name = fpot.profile_option_name
       AND fpot.language = 'US'
       AND fpov.level_value = fat.application_id
       AND fat.language = 'US'
       AND fpov.level_id = 10002                       -- Application Level ID
       AND UPPER (fat.application_name) LIKE '%HUMAN%RES%'

Profile’s Enabled at Responsibility Level

SELECT frt.responsibility_name,
       fpot.user_profile_option_name,
       fpov.profile_option_value
  FROM fnd_profile_option_values fpov,
       fnd_profile_options fpo,
       fnd_profile_options_tl fpot,
       fnd_responsibility_tl frt
 WHERE     fpo.profile_option_id = fpov.profile_option_id
       AND fpo.profile_option_name = fpot.profile_option_name
       AND fpot.language = 'US'
       AND fpov.level_value = frt.responsibility_id(+)
       AND frt.language = 'US'
       AND fpov.level_id = 10003                     -- Resposibility Level ID
       AND UPPER (frt.responsibility_name) LIKE
              '%XXX IRECRUITMENT RECRUITER%'

Profile’s Enabled at User Level

SELECT fu.user_name, fpot.user_profile_option_name,fpov.profile_option_value
  FROM fnd_profile_option_values fpov,
       fnd_profile_options fpo,
       fnd_profile_options_tl fpot,
       fnd_user fu
 WHERE     fpo.profile_option_id = fpov.profile_option_id
       AND fpo.profile_option_name = fpot.profile_option_name
       AND fpot.language = 'US'
       AND fpov.level_value = fu.user_id
       AND fu.user_name = 'BIJOYJ'

       AND fpov.level_id = 10004  -- User Level ID