Resolved - So I feel like an idiot as just realised why the report was defaulting to the incorrect year on load - turns out I had 2 parameters with the same name, but different defaults that were conflicting - deleted one and changed the defaults and it worked…sorry
So we have a dashboard with multiple tables filled with a variety of KPIs and I have created a script on a filter to work based on Parameter Changed Value - essentially you choose a year, and it calculate the correct period for a Range Filter to then apply to the tables created. Upon click this works a treat:
// Identify the view parameters
var vp1 = this.parentView.control.getViewParameterByName(“Year Filter”);
var vp2 = this.parentView.control.getViewParameterByName(“Range Filter”);
var today = new Date();
var lastmonth = new Date();
// Clear tokens and values
//Set the lower boundary to the value of the 1st view paramer
vp2.parameterValue.lowerBoundaryValue = vp1.parameterValue.value.memberTime;
//Set the upper boundary to the value of the 1st view parameter
var upperDate = new Date(vp1.parameterValue.value.upperBoundaryTime.getTime());
vp2.parameterValue.upperBoundaryValue = upperDate > today ? lastmonth : upperDate
// Set the last modified time so this parameter takes precedence over any others
// Update all the connected adapters with the newly modified values
// Includes data visualizations and filter controls
Essentially what I want to happen when a user loads the report for the first time in a day, I want the default i.e Current Year to show in the Year Filter, and the report to recognise this and set the Range filter to follow the same rules as the above script states (essentially current year has not completed, select the last day of the previous month).
Based on other posts in the forum, I have removed the .parentView. from the initial Identification script, and then copied the script into the dashboard loading action, but sadly this didn’t work (with or without .parentView. in the script).
I then started thinking maybe I just need to force the filters on load to accept a date range, but as I try to slowly build this, I keep seeing an error in the Developer Tools of "Cannot read property ‘control’ of undefined, which I am assuming as this is at the very beginning of script, I have zero chance of it going forward.
Any assistance would be really appreciated as this is the final hurdle for this and another dashboard so that our users are presented with the latest state of play as soon as the report loads.
Thank you as always