Sunday 16 August 2020

Script to set Profile Value at Responsibility level from backend


declare 
   v_check            boolean;
   v_profile_name1 varchar2(240) := 'MO: Operating Unit';
   v_value1          varchar2(240) := '111'; --select ORGANIZATION_ID from hr_operating_units where name ='XXXX US OU'
   v_profile1           varchar2(240);
   
   v_resp_name    varchar2(240)   := 'XXXX US OM Super User';
   v_resp_id      number;
   v_resp_app_id number;
begin 

    select profile_option_name
    into v_profile1
    from fnd_profile_options_tl
    where 1=1
    and user_profile_option_name = v_profile_name1 ;
  
    select responsibility_id      
        , application_id   
    into v_resp_id      
        , v_resp_app_id   
    from fnd_responsibility_tl  
    where responsibility_name = v_resp_name ;

     
v_check := fnd_profile.save( x_name => v_profile1   --profile_option_name          
, x_value => v_value1 --profile_option_value
                                , x_level_name => 'RESP'               
                                , x_level_value => v_resp_id             
                                , x_level_value_app_id => v_resp_app_id) ; 


if v_check then
dbms_output.put_line('Profile '||v_profile_name1||' updated with '||v_value1);
commit;
else
dbms_output.put_line('Error while updating Profile '||v_profile_name1||' with value '||v_value1);
end if;

exception
when others then
      dbms_output.put_line('Error: '||sqlerrm);
end;
/

No comments:

Post a Comment