Monday, December 3, 2012

Script to get profile option values at different levels

>> Please provide the User Profile Option Name as an Input.

------------------------
-----------
select fpo.profile_option_name "Profile Option Name"
        , fpot.user_profile_option_name "User Profile Option Name"
        , fpot.description
        , fpo.start_date_active "Start Active Date"
        , fpo.end_date_active "End Date Active"
        , fpo.creation_date "Creation Date"
        , fu.user_name "Created By"
        , 'Site' "Level"
        , 'SITE' "Level Value"
        , fpov.profile_option_value "Profile Option Value"
    from fnd_profile_options_tl fpot
       , fnd_profile_options fpo
       , fnd_profile_option_values fpov
       , fnd_user fu
   where fpot.user_profile_option_name like '%'||:profile_name||'%'
     and fpot.profile_option_name = fpo.profile_option_name
     and fpo.application_id = fpov.application_id
     and fpo.profile_option_id = fpov.profile_option_id
     and fpo.created_by = fu.user_id
     and fpot.language = userenv('Lang')
     and fpov.level_id = 10001 /* site level */
union all
   select fpo.profile_option_name "Profile Option Name"
        , fpot.user_profile_option_name "User Profile Option Name"
        , fpot.description
        , fpo.start_date_active "Start Active Date"
        , fpo.end_date_active "End Date Active"
        , fpo.creation_date "Creation Date"
        , fu.user_name "Created By"
        , 'Appl' "Level"
        , fa.application_name "Level Value"
        , fpov.profile_option_value "Profile Option Value"
   from fnd_profile_options_tl fpot
       , fnd_profile_options fpo
       , fnd_profile_option_values fpov
       , fnd_user fu
       , fnd_application_tl fa
  where fpot.user_profile_option_name like '%'||:profile_name||'%'
    and fpot.profile_option_name = fpo.profile_option_name
    and fpo.profile_option_id = fpov.profile_option_id
    and fpo.created_by = fu.user_id
    and fpot.language = userenv('Lang')
    and fpov.level_id = 10002 /* application level */
    and fpov.level_value = fa.application_id
union all
  select fpo.profile_option_name "Profile Option Name"
        , fpot.user_profile_option_name "User Profile Option Name"
        , fpot.description
        , fpo.start_date_active "Start Active Date"
        , fpo.end_date_active "End Date Active"
        , fpo.creation_date "Creation Date"
        , fu.user_name "Created By"
        , 'Resp' "Level"
        , frt.responsibility_name "Level Value"
        , fpov.profile_option_value "Profile Option Value"
   from fnd_profile_options_tl fpot
       , fnd_profile_options fpo
       , fnd_profile_option_values fpov
       , fnd_user fu
       , fnd_responsibility_tl frt
  where fpot.user_profile_option_name like '%'||:profile_name||'%'
    and fpot.profile_option_name = fpo.profile_option_name
    and fpo.profile_option_id = fpov.profile_option_id
    and fpo.created_by = fu.user_id
    and frt.language = userenv('Lang')
    and fpot.language = userenv('Lang')
    and fpov.level_id = 10003 /*responsibility level */
    and fpov.level_value = frt.responsibility_id
    and fpov.level_value_application_id = frt.application_id
union all
select fpo.profile_option_name "Profile Option Name"
        , fpot.user_profile_option_name "User Profile Option Name"
       , fpot.description
       , fpo.start_date_active "Start Active Date"
       , fpo.end_date_active "End Date Active"
       , fpo.creation_date "Creation Date"
       , fu.user_name "Created By"
       , 'User' "Level"
       , fu2.user_name "Level Value"
       , fpov.profile_option_value "Profile Option Value"
   from fnd_profile_options_tl fpot
       , fnd_profile_options fpo
       , fnd_profile_option_values fpov
       , fnd_user fu
       , fnd_user fu2
  where fpot.user_profile_option_name like '%'||:profile_name||'%'
    and fpot.profile_option_name = fpo.profile_option_name
    and fpo.profile_option_id = fpov.profile_option_id
    and fpo.created_by = fu.user_id
    and fpov.level_id = 10004 /* user level */
    and fpov.level_value = fu2.user_id
    and fpot.language = userenv('Lang')
order by  "User Profile Option Name", "Level", "Level Value"

No comments:

Post a Comment