Difference between revisions of "Criteria Template"

From SmartWiki
Jump to: navigation, search
(Variables)
(Variables)
 
(12 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
The Criteria Template section on the [[Report Template]] tab of the [[Creating a Basic Report|Edit Report Page]] defines the criteria section of a custom report template containing the prompt(s) for report [[parameter]](s) when [[criteria|report criteria]] are used.
 
The Criteria Template section on the [[Report Template]] tab of the [[Creating a Basic Report|Edit Report Page]] defines the criteria section of a custom report template containing the prompt(s) for report [[parameter]](s) when [[criteria|report criteria]] are used.
  
The Criteria Template section accepts HTML code. When the Criteria Template is used, the report parameter prompt does not manifest as a pop-up when the report is run, but remains at the top of the page.  
+
When the Criteria Template is used, the report parameter prompt does not manifest as a pop-up when the report is run, but remains at the top of the page.  
  
'''Example:''' A simple report is built as follows that prompts the user for the first name of a contact when run:<br /><br />
+
''Example'': Our report prompts the user for two criteria:<br />
 +
[[Image:CriteriaTemplate-CriteriaSetInReportSimple.png|link=]]
  
[[Image:CriteriaTemplate-ReportBuilder.png|link=|400px]]<br /><br />
+
When we run the report, we see the following criteria prompt:<br />
The default prompt for the report will appear as follows, a concatenation of the recordset and field name specified in the [[Report Builder]]:<br /><br />
+
[[Image:CriteriaTemplate-DefaultCriteria.png|link=]]
[[Image:CriteriaTemplate-DefaultPrompt.png|link=|350px]]<br /><br />
 
Right click on the page and choose the option in your [[browser]] that will expose the page HTML source. Then scroll down to and copy the section that contains the criteria table: <br /><br />
 
[[Image:CriteriaTemplate-SourceTable.png|link=|450px]]<br /><br />
 
Then go to your Edit Report page, select the Report Template tab and paste the HTML code for the criteria table into the Criteria Template section:<br /><br />
 
[[Image:CriteriaTemplate-PasteIntoTemplate.png|link=|650px]]<br /><br />
 
You can then edit the HTML code:<br /><br />
 
[[Image:CriteriaTemplate-EditedTemplate.png|link=|650px]]<br /><br />
 
The resultant report, when run, will contain the criteria section you have defined at the top of the report:<br /><br />
 
[[Image:CriteriaTemplate-ResultantReport.png|link=|450px]]
 
<br /><br />
 
  
 +
However, we want to make the ''First Name'' parameter default to the current user's first name. For this we need to build a custom ''Criteria Template''.
 +
 +
In the [[Creating a Basic Report|Edit Report Page]], we switch to the [[Report Template]] tab and enter the following in the ''Criteria Template'' section:<br />
 +
 +
<pre style="white-space: pre-wrap;  white-space: -moz-pre-wrap;  white-space: -pre-wrap;  white-space: -o-pre-wrap;  word-wrap: break-word;"><table>
 +
  <tr>
 +
      <th class=Sub>
 +
        @arg1.label@
 +
      </th>
 +
      <td>
 +
        @arg1@
 +
      </td>
 +
  </tr>
 +
  <tr>
 +
      <th class=Sub>
 +
        @arg2.label@
 +
      </th>
 +
      <td>
 +
        <input type=text id=@arg2.id@ name=@arg2.id@ value="@me.firstname@">
 +
      </td>
 +
  </tr>
 +
  <tr>
 +
      <td colspan=2 class=Submit>
 +
        @submitbutton@ @exportbutton@
 +
      </td>
 +
  </tr>
 +
</table></pre>
 +
<!--[[Image:CriteriaTemplate-SampleCriteriaTemplate.png|link=]]-->
 +
 +
Notice that the first criteria is left unchanged. The second criteria is where we create our own HTML input element and define it as the second criteria. The ''value'' is defaulted to the user's first name.<br />
 +
[[Image:CriteriaTemplate-RevisedCriteria.png|link=]]
 +
 +
Note also that the @submitbutton@ and @exportbutton@ variables in the new ''Criteria Template'' expose the ''Submit'' and ''Export'' buttons on the page.
  
 
==Variables==
 
==Variables==
Line 27: Line 51:
 
* @fileexportbutton@
 
* @fileexportbutton@
  
For reports containing multiple criteria, the variable syntax for the different criteria elements is arg''n'' where ''n'' is the order of the criteria defined in the [[Report Builder]].
+
{{MultipleCriteriaVariableSyntax}}
* @arg1.label@ returns the text label of the input
 
* @arg1@ returns the input field for the criteria
 
* @arg1.id@ returns the element ID of the input
 
  
 
==Notes==
 
==Notes==

Latest revision as of 13:17, 8 December 2014

The Criteria Template section on the Report Template tab of the Edit Report Page defines the criteria section of a custom report template containing the prompt(s) for report parameter(s) when report criteria are used.

When the Criteria Template is used, the report parameter prompt does not manifest as a pop-up when the report is run, but remains at the top of the page.

Example: Our report prompts the user for two criteria:
CriteriaTemplate-CriteriaSetInReportSimple.png

When we run the report, we see the following criteria prompt:
CriteriaTemplate-DefaultCriteria.png

However, we want to make the First Name parameter default to the current user's first name. For this we need to build a custom Criteria Template.

In the Edit Report Page, we switch to the Report Template tab and enter the following in the Criteria Template section:

<table>
   <tr>
      <th class=Sub>
         @arg1.label@
      </th>
      <td>
         @arg1@
      </td>
   </tr>
   <tr>
      <th class=Sub>
         @arg2.label@
      </th>
      <td>
         <input type=text id=@arg2.id@ name=@arg2.id@ value="@me.firstname@">
      </td>
   </tr>
   <tr>
      <td colspan=2 class=Submit>
         @submitbutton@ @exportbutton@
      </td>
   </tr>
</table>

Notice that the first criteria is left unchanged. The second criteria is where we create our own HTML input element and define it as the second criteria. The value is defaulted to the user's first name.
CriteriaTemplate-RevisedCriteria.png

Note also that the @submitbutton@ and @exportbutton@ variables in the new Criteria Template expose the Submit and Export buttons on the page.

Variables

To show certain buttons on the criteria page, you can reference variables in the Criteria Template:

  • @submitbutton@
  • @exportbutton@
  • @fileexportbutton@

For reports containing multiple criteria, the variable syntax for the different criteria elements is argn where n is the order of the criteria defined in the Report Builder.

  • @argn.label@ returns the text label of the input
  • @argn@ returns the input field for the criteria
  • @argn.id@ returns the element ID of the input

Notes

  • The Criteria template is not rebuilt when the report is rebuilt.

See Also