Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to URL Encode Page Item Correctly - APEX 21.1

McRiversJul 20 2021 — edited Jul 20 2021

I have a RESET_PSWD button on a Form that calls a dynamic action with 4 true actions defined.
 Confirm Action
Execute Server-side Code - PL/SQL procedure to generate new temp pswd
Execute Server-side Code - PL/SQL procedure to generate modal url using APEX_PAGE.GET_URL
Execute JavaScript Code - use url from step 3 to open modal
The goal of the DA is to generate a Temp Password, build a URL to the modal (passing in the new Temp Password from Step 2), and then navigate to the modal. Between Step 2 and Step 3 the value in P7_TEMP_PSWD is getting truncated due to special characters not being url encoded correctly between the request calls. 

-- package procedure to get & set url for confirmation modal (Step 3)
PROCEDURE get_feedback_url (
  p_username   VARCHAR2,
  p_temp_pswd  VARCHAR2
) IS

  vcPswdEncoded  VARCHAR2(1000);
  vcURL          VARCHAR2(1000);
  vcValueList    VARCHAR2(1000);

BEGIN

  vcPswdEncoded := APEX_UTIL.URL_ENCODE(p_temp_pswd);
  vcValueList   := p_username ||','|| vcPswdEncoded;

  vcURL := APEX_PAGE.GET_URL(p_page   => '12',
                              p_items  => 'P12_USERNAME,P12_TEMP_PSWD',
                              p_values => vcValueList,
                              p_plain_url => TRUE);

  APEX_UTIL.SET_SESSION_STATE('P7_FEEDBACK_URL', vcURL);

EXCEPTION
  WHEN OTHERS THEN
    csa.rsn_logger.log_error(p_rsn_app => 'RSNUM',
                              p_app_loc => 'rsnum_user.get_feedback_url',
                              p_log_msg => SQLERRM);
END;

I am trying to url encode the temp pswd before building the url, but I am getting the following results:
debug_log.pngThe value after using APEX_UTIL.ENCODE_URL is what I want, but it seems like APEX_PAGE.GET_URL also encoding the values so '%' is encoded again. Is there a way to opt out of GET_URL doing this? The reason why I am using ENCODE_URL in the first place is because APEX does was not encode '#' (and a few other characters) by default and that was causing me problems originally.

This post has been answered by McRivers on Jul 20 2021
Jump to Answer
Comments
Post Details
Added on Jul 20 2021
3 comments
1,681 views