In this article
Date filter scripts allow you to create date-range filters based on date ranges defined in the Date Filter component, and thereby filter content in report components and on report pages, and set the text of a Text component.
Go to Filter tree > Insert a filter script > ScriptReport tree > A Component > Script > Render.
The following date filter scripts are available:
- Filter script for the Date Filter component - this defines a particular date filter component via a start date variable ('interview_start in the example below) and a parameter name ('p2' in the example below). It is created and stored as a Filter script, and is assigned to a relevant Date Filter component by dragging it onto the component.
- Date range pre-defining script - this overrides the default ALL DATES value. It is stored as a render script of an arbitrary component (but not a Date Filter) or a page in the report.
- Date Filter Text component script - outputs the date range set in the linked Date Filter as a text string in a Text component. It is created and stored as a render script of a Text component.
Filter Script for the Date Filter component:
filter.Expression=report.DateRangeUtils.GetRollingDateRangeExpression('interview_start','p2');
log.LogDebug("filter"+filter.Expression);Script that pre-defines Date Filter values:
//Setting the date filter to display data for Current month to date if filter is not already set
var p2_value = state.Parameters.GetString('p2');
if (!p2_value){
var p_new = new ParameterValueResponse(report.DateRangeUtils.GetDateRangeOptions.Months.Current());
state.Parameters['p2'] = p_new;
}
Date Filter Text Component script:
var di: DateInfo = report.DateRangeUtils.GetDateInfo('p2');
text.Output.Append(di.Range.start);Date Filter Text Component script:
var di: DateInfo = report.DateRangeUtils.GetDateInfo('p2');
text.Output.Append(di.Range.start);