Monday, October 23, 2017

API to Set Profile Option Value from Backend

Use API fnd_profile.save to set profile value from backend. As shown in below screenshot for Profile Option "HZ: Generate Party Number" I would like to set to "Yes".


 

Find the Profile Option Name for given user profile option name with below query.

SELECT fpot.user_profile_option_name, fpot.profile_option_name,
       DECODE (TO_CHAR (fpov.level_id),
                 '10001', 'Site',
                 '10002', 'Application',
                 '10003', 'Responsibility',
                 '10004', 'User',
                 'Unknown') "PROFILE_LEVEL"
                 ,DECODE(fpov.profile_option_value, 'Y', 'Yes'
                                                  , 'N', 'No') profile_option_value
  FROM fnd_profile_options_tl fpot
      ,fnd_profile_options fpo
      ,fnd_profile_option_values fpov
 WHERE fpot.user_profile_option_name = 'HZ: Generate Party Number'
   AND fpot.profile_option_name = fpo.profile_option_name
   AND fpov.profile_option_id = fpo.profile_option_id
   AND DECODE (TO_CHAR (fpov.level_id),
                 '10001', 'Site',
                 '10002', 'Application',
                 '10003', 'Responsibility',
                 '10004', 'User',
                 'Unknown') = 'Site'     



Execute the below code to set Profile Option "HZ: Generate Party Number" value to "Yes"
DECLARE
   l_status              BOOLEAN;
   l_user_id           NUMBER;
   l_resp_id           NUMBER;
   l_resp_appl_id      NUMBER;
BEGIN
   BEGIN
    SELECT user_id
      INTO l_user_id
      FROM fnd_user
     WHERE user_name = '<<USER_NAME>>';    
   END;  
   BEGIN
    SELECT responsibility_id, application_id
      INTO l_resp_id, l_resp_appl_id
      FROM fnd_responsibility_tl
     WHERE responsibility_name = 'System Administrator'  ; 
   END;
  
   fnd_global.apps_initialize ( l_user_id, l_resp_id, l_resp_appl_id ) ;
   l_status :=
      fnd_profile.save (x_name       => 'HZ_GENERATE_PARTY_NUMBER'-- Profile name you are setting
                       ,x_value      => 'Y'-- Profile value you are setting
                       ,x_level_name => 'SITE'-- Level that you're setting at: 'SITE','APPL','RESP','USER', etc.
                        );
   IF l_status
   THEN
      DBMS_OUTPUT.put_line ('l_status = TRUE - Profile Updated');
   ELSE
      DBMS_OUTPUT.put_line ('l_status = FALSE - Profile not Updated');
   END IF;

   COMMIT;
END;



Check the value from Application:-
Navigation:
  System Administrator-->Profile--> System
Query with Profile Option Name "HZ: Generate Party Number"--> Click on Find button 

Profile Value is changed now.

1 comment:

  1. is not saving at the end I tried to commit it but still not working

    ReplyDelete

SupplierAddressImportTemplate.xlsm South Africa Suburb Field mapping in POZ_SUPPLIER_ADDRESSES_INT

Suburb mpping in Supplier Address Import Template will be mapped to Address Element Attribute2 (HZ_LOCATIONS. ADDR_ELEMENT_ATTRIBUTE2)