Thursday, May 23, 2013

Script to Assign the Profile option for a specific Level

 The below script is to enable profile option at USER level, for a given list of Users.

For setting a Profile Option Value from back end we need the Following three parameters;
    1. Name of Profile Option
    2. Value for the profile option which we want to set.
    3. The level at which we want to set the profile option value.

    Parameters Explanation:
    Profile_Option_Name  : Profile name you are setting
    Profile_Option_Value : Profile value you are setting
    Level                : Level that you're setting at. It could be 'SITE', 'APPL','RESP', or 'USER'
    Level_Value     : Level value that you are setting at,
                           e.g. user id for 'USER' level. This is not used at site level
    Level_Value_App_id   : Only used for 'RESP' level. Application_Id of the responsibility.

DECLARE
   l_result    BOOLEAN;
   l_profile   VARCHAR2 (150);
BEGIN
   SELECT   profile_option_name
     INTO   l_profile
     FROM   FND_PROFILE_OPTIONS_TL
    WHERE   user_profile_option_name = 'ABC'
/* An example of the value to be used in the above condition to match with user_profile_option_name. Use MO: Operating Unit if you are trying to set operating unit. If you use MO: Operating Unit you get ORG_ID in l_profile variable */


   FOR rec IN (SELECT   user_id
                 FROM   fnd_user
                WHERE   user_name IN ('XXXX', 'YYYY', 'ZZZZ'))
   LOOP
      l_result :=
         FND_PROFILE.SAVE (l_profile,
                           'Y',
                           'USER',
                           rec.user_id,
                           NULL,
                           NULL);

      IF l_result
      THEN
         DBMS_OUTPUT.put_line ('Success');
         COMMIT;
      ELSE
         DBMS_OUTPUT.put_line ('Error');
      END IF;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (' Exception in the Main');
END;

/



***Please leave a comment***

1 comment:

Please provide your valuable feedback which helps us to improve the content.