Opening Modal Dialog page using JavaScript

In APEX, when there is a requirement for opening pages
dynamically JavaScript must be used. Normal pages can be easily opened in
JavaScript’s by mentioning the URL using window.location, but Modal Dialog cannot
be opened. URL will not be framed correctly for Modal Dialog pages.

Below code can be used for opening dialog pages
dynamically using JavaScript’s in APEX.

Sample Code:

/*Frame the URL parts
separately for passing parameters dynamically.
URL with App_ID,Page_ID,Session_ID
*/
var c = “f?p=&APP_ID.:1398:&SESSION.”;
/*Pass the Input
Parameters with values
To escape the special
characters which are not allowed in URL, JavaScript escape() function can be
used. */
var d = ‘::NO::P1398_REGION_CODE,P1398_REPORT_OPTION,P1398_DPD_DAYS,P1398_ASSET_CLASS,P1398_REPORT_MONTH,P1398_CONTRACT_TYPE,P1398_SORT_ORDER,P1398_PREV_MNTH_MINUS_1,P1398_PREV_MNTH_MINUS_2,P1398_PREV_MNTH_MINUS_3,P1398_CONTRACT_FY_START_DATE,P1398_SEGMENT_CODE,P1398_SUB_SEGMENT,P1398_SEGMENT_CODE_NAME,P1398_SUB_SEGMENT_NAME:’+strRgnCode+“,”+$x(“P1392_REPORT_OPTION”).value+“,”+$x(“P1392_DPD_DAYS”).value+“,”+$x(“P1392_ASSET_CLASS”).value+“,”+$x(“P1392_REPORT_MONTH”).value+“,”+$x(“P1392_CONTRACT_TYPE”).value+“,”+“DPD_ASC”+“,”+$x(“P1392_PREV_MNTH_MINUS_1”).value+“,”+$x(“P1392_PREV_MNTH_MINUS_2”).value+“,”+$x(“P1392_PREV_MNTH_MINUS_3”).value+“,”+$x(“P1392_CONTRACT_FY_START_DATE”).value+“,”+$x(“P1392_SEGMENT_CODE”).value+“,”+$x(“P1392_SUB_SEGMENT”).value+“,”+escape(strSegmentName)+“,”+escape(strSubSegmentName);
/*For opening
dialogs/pages using JavaScript apex.navigation.dialog must be used*/
var e = (“javascript:apex.navigation.dialog(‘f?p=&APP_ID.:1398:&SESSION.”).length;
var f = c.slice(0,e)+d+c.slice(e);
f=f.replace(“:::::”,“:”);
console.log(f);   
window.location.href=f;
  • April 16, 2018 | 17 views
  • Comments