Purpose
Applies To
Custom Planning Style Reports. Custom planning style reports are typically embedded within an add or edit screen. This user custom exit allows these reports to be run outside of these screens. The base code triggers the request to run the report from an internal flag and this cannot be accessed outside the add and edit pages. A UDF field is used to pass this information and to act as a filter.
Signature
public boolean ucSearchPlanningReport(
HttpServletRequest request,
HttpServletResponse response,
Connection dbconn,
SesameSession session)
throws Exception
Notes
Example
-
Create a user defined field to be used as the flag.
-
For example, create a field in the data dictionary as follows:
Fixed Name = UC_PLAN_RUN
Title to display = Execute UC Plan Report
Display Type = Text Field
Filter Criteria = Yes
-
For example, create a field in the data dictionary as follows:
-
Modify or create a Planning Report
-
Add the following filter:
“Execute UC Plan Report” (UC_PLAN_RUN) = Y
-
Save the Report.
-
Add the following filter:
-
Modify the user custom exit
ucSearchPlanningReport
as follows:Report report = (Report)session.getAttribute(PlanningController.SES_PLAN_MASTER_REPORT); String title = report.getTitle(); String relGroupId = report.getHierarchyId(); if ("2".equals(relGroupId)) { FilterGroup filterGroup = report.getFilterGroup(); Filter f = filterGroup.getFilter("UC_PLAN_RUN"); // do not run unless the runUC flag has been set. if(f==null || (f!=null && !"Y".equals(f.getFilterCriteria().get(0)))) return; // check to see if the f = filterGroup.getFilter("REPORT_START_DATE"); if(f==null) return; String reportStartDate= (String)f.getFilterCriteria().get(0); f = filterGroup.getFilter("REPORT_END_DATE"); if(f==null) return; String reportEndDate = (String)f.getFilterCriteria().get(0); // set start date in session so that the report begins 7 days before the delivery date. try { if (TextManager.isStringVisible(reportStartDate)) { Calendar dateCal = Convert.getCalendarDayFromString(session, reportStartDate); dateCal.add(Calendar.DATE,-7); Date startDt = dateCal.getTime(); session.setAttribute(PlanningController.SES_START_DT, startDt); } } catch (Exception subE) { Z.logtrace(subE, Log.ERROR); } // exit if the report start and end dates are not set. if( TextManager.isStringInvisible(reportStartDate) || TextManager.isStringInvisible(reportEndDate)) return; // remove these fields from the report because we do not want them used // to filter the results. filterGroup.removeFilter("REPORT_START_DATE"); filterGroup.removeFilter("REPORT_END_DATE"); filterGroup.removeFilter("UC_PLAN_RUN"); // set the sort order based on Product Name. SortOrder so = new SortOrder(); SortOrderField sof = new SortOrderField(); sof.setConnection(dbconn); sof.setDDName("PRODUCT_NAME_UDF"); sof.setOrderRank(0); sof.setSortDirection("ASC"); so.addField(sof); report.addSortOrder(so); // the Report Start Date and the Report End Date are required by UserJavaScript. // Place these values in session, so that they are placed on the planning report. String ucParams = "={p_from_date_delivery : \""+deliveryDate+"\", p_to_date_pickup : \""+collectionDate+"\"};"; session.setAttribute("UC_RUN_PLANNING_CUSTOM",ucParams); }
-
Execute custom JavaScript based on the contents of the ucParams above.
/** * ucPlanningReportPostLoad */ function ucPlanningReportPostLoad(colMove, pageMove) { var runUC = false; runUC = (typeof(ucParams) != 'undefined' && typeof(ucParams.p_from_date_delivery) != 'undefined'); try { if ( runUC) { // do stuff alert(" Calling from ucPlanningReportPost Load"); // changing background colors based on a custom ajax call } catch (err) { // ignore the error for now... alert('ucPlanningReportPostLoad:'+ err); }