Report Chooser
Copy
You need a dialog to present a set of Reporting Services-based Reports to choose from for the selected Item.
Technique
A Client Method based Report is used to present a Form to get the Report choice. The user selection is mapped to a query_string for the Report Server request via the RSGatwway.aspx page. This is similar to recipe 8.1 User Input Form but in this case, we do want the ID for the selected Item to be passed as a Named Parameter on the query_string.
Procedure for building a Report Chooser dialog for Reporting Services based Reports:
- Login to Aras Innovator as admin.
- Navigate to the Administration->Lists off the Main Tree.
- Open a new List Item
Set the List Item properties as follows:
- Name =
ReportChooserOptions - Add values with Labels and Values that match the names of your Reports as deployed to the Report Server.
- Name =
- Save, unlock, and close
- Navigate to the Administration->Forms off the Main Tree.
- Open a new Form Item.
Set the Form Item properties as follows:
- Name = Report Chooser (this can be any name you want)
Add a form event that fires onLoad
- Name the Method ‘
ReportChooser_onLoad’ (this can be anything you want)
- Name the Method ‘
Add a new Radio Button List:
- Name this field ‘rdio1’
Add a Button field with a label Submit:
- Create a Field Event that fires onClick.
- Name the Method ‘
ReportChooser_OnClick’ (this can be anything you want).
- Save, unlock, and close.
- Navigate to the Administration->Methods off the Main Tree.
- Edit the
ReportChooser_OnClickMethod Item. Set the method code as shown:
var inputOptions = document.getElementsByTagName(“input”);var retVal = [];for (var i = 0; i < inputOptions.length; i++){if (inputOptions[i].className != “arasCheckboxOrRadio”){continue;}if (inputOptions[i].checked === true){retVal[‘reportSelected’] = inputOptions[i].value;parent.args.dialog.result = retVal;}}parent.args.dialog.close();- Save, unlock, and close.
- Create another Method Item (‘ReportChooser_OpenDialog’), this can be called whatever you want).
Set the method code as shown:
- The URL query strings (“&np:”) should reference the parameter as defined in the report.
var inn = this.getInnovator();var itemIDs = typeof(thisItem)!=="undefined” ? thisItem.getID() : aras.getMainWindow().main.work.grid.getSelectedItemIds(',’).split(',’)[0];var ReportInputForm = inn.newItem(“Form”, “get”);ReportInputForm.setAttribute(“select”, “id, width, height”);ReportInputForm.setProperty(“keyed_name”, “ReportChooser”);ReportInputForm = ReportInputForm.apply();var param ={title: “ReportChooser”,formId: ReportInputForm.getID(),isEditMode : “1",aras : aras,opener : window,innovator : inn,item : this,dialogHeight: ReportInputForm.getProperty(‘height’,'800'),dialogWidth: ReportInputForm.getProperty(‘width’,'600'),content: ‘ShowFormAsADialog.html’}function callback(dialogWrapper){var result = dialogWrapper.result;if (!result || !result[‘reportSelected’]){ return; }var test=0;var url = aras.getServerBaseURL() +“RSGateway.aspx?irs:Report=" + result[‘reportSelected’] +"&np:id=" + itemIDs; // and the Item ID.var w = top.window.open();w.location = url;return "<html></html>";}var wnd = aras.getMainWindow();wnd = wnd === top ? wnd.main : top;wnd.ArasModules.Dialog.show(“iframe”, param).promise.then(callback);
- The URL query strings (“&np:”) should reference the parameter as defined in the report.
- Save, Unlock, and Close
- Edit the ReportChooser_onLoad Method Item.
Set the method code as shown.
var radioButtonSpan = getFieldByName(‘rdio1') uses the name of the radio button field as defined on the ReportChooser Form Item.
var radioButtonSpan = getFieldByName(‘rdio1');var sysValueSpan = radioButtonSpan.getElementsByClassName(“sys_f_value”);if (sysValueSpan.length != 1){return;}sysValueSpan = sysValueSpan[0];var inn = this.params.thisItem.getInnovator();var reports = inn.newItem(“List”, “get”);reports.setAttribute(“levels”, “2");reports.setProperty(“keyed_name”, “ReportChooserOptions”);reports = reports.apply();var reportRel;if (reports.IsError() || reports.getItemCount > 1){return false;}else{reportRel = reports.getRelationships(“Value”);}for (var i = 0; i < reportRel.getItemCount(); i++){var value = reportRel.getItemByIndex(i);var valueLabel = value.getProperty(“label”, "");var reportButtonSpan = document.createElement(“span”);reportButtonSpan.setAttribute(“id”, “MyRadio”);reportButtonSpan.setAttribute(“name”, valueLabel);reportButtonSpan.setAttribute(“style”, “position:relative;display:block;");var radioInput = document.createElement(“input”);radioInput.setAttribute(“type”, “radio”);radioInput.setAttribute(“value”, valueLabel);radioInput.setAttribute(“name”, “ReportOptions”);radioInput.setAttribute(“class”, “arasCheckboxOrRadio”);var reportLabel = document.createElement(“label”);reportLabel.setAttribute(“for”, “MyRadio_id”);reportButtonSpan.appendChild(radioInput);reportButtonSpan.appendChild(radioInput);reportButtonSpan.appendChild(reportLabel);reportButtonSpan.appendChild(document.createTextNode(valueLabel));sysValueSpan.appendChild(reportButtonSpan);}
- Save, unlock, and close.
- Navigate to the Administration->Reports off the Main Tree.
- Open a new Report Item.
Set the Report Item properties as follows:
- Name = Report Chooser (this can be anything you want).
- Type = Item (You do not need the report_query template when prompted).
- Location = Client; this is required because the ReportChooser_OpenDialog Method returns an HTML page with JavaScript that needs to be parsed. The Client-side Report only writes the transformed page to the browser window and thus the JavaScript is not parsed.
- Target = None; the windows will be created by ReportChooser_OpenDialog.
- Method = ReportChooser_OpenDialog
- Report Query = Leave blank; it is currently not used for this purpose
- Save, unlock, and close the Report.
- Navigate to the Administration->ItemTypes off the Main Tree.
- Search for the ItemType for this Report.
- Edit the ItemType and select the Reports Tab.
- Add an Existing related Item and select this Report.
- Save, unlock, and close the ItemType.
The Report should now appear on the Report menu when the Item is selected. When the user clicks Submit the selected Report, the actual Report is requested from the Report Server via the RSGateway.
The ID for the selected Item is automatically passed as a Named Parameter np:id so you must name your Named Parameter in the SQL query with lowercase id also.