Setting Parameter value on dashboard ready event

Hi all,

So I have come up against something which is confusing me and I am wondering if A) anyone has had the same issue, B) I am doing something wrong or C) Something is wrong with the software?

I am trying to run a script on a dashboard load using the Ready section to set a parameter filter value. This is due to the fact I am calling a procedure to get the persons account name, and then use that name on the parameter filter giving me an ability to filter the dashboard depending on the person.

https://www.dundas.com/support/learning/documentation/create-view-content/how-to/set-filter-value-by-script

I am using the above page to provide me with the script to set a filter, and below is my “code”

The weird thing is, this code I know works when attached to a manual button press. However, when I try and run it from the ready event it doesn’t seem to want to work? My understanding of the ready event on the dashboard is that the whole dashboard is loaded before the ready event is run? if that is the case, then the view para should have been loaded meaning it is exactly the same as if I had a button on the page and manually pressed it…

Any suggestions or comments are appreciated!
note: I have to reverse the account name to apply to the filter, annoying but thats what the first bit of the script is for.

Blockquote
//Get display Name
var name = dundas.context.currentSession.accountDisplayName;
//extract first and last name from name…
// get lenth of string to the comma placement
var comma_str_lgth = name.search(",");
// extract lastname value from name
var lastname = name.substring(0,comma_str_lgth);
// extract firstname value from name
var firstname = name.substring(comma_str_lgth + 2);
// combine them back together in the correct format
var wholename = lastname.concat(" “,firstname);
// set unique name str to pass
var unique_name_start = “[_Employee - Navixa History].[Employee Name].&[”;
var unique_name = unique_name_start.concat(wholename,”]");
//Put into a label for debug purposes.
Namelabel.labelText = wholename;
//adjust filter value to be name
var viewParameter = this.parentView.control.getViewParameterByName(“viewParameter1”);
var filterValue = new dundas.data.MemberValue({
hierarchyUniqueName: “[_Employee - Navixa History].[Employee Name]”,
levelUniqueName: “[_Employee - Navixa History].[Employee Name].[Employee Name]”,
uniqueName: unique_name
});
viewParameter.parameterValue.token = null;
viewParameter.parameterValue.values.length = 0;
viewParameter.parameterValue.values.push(filterValue);
viewParameter.invalidateParameterValueLastModifiedTime();
viewParameter.refreshAllAdapters();

Thank you

2 Likes

Hello,

You have to use:
this.control.getViewParameterByName(“viewParameter1”); without parentView.

parentView is used only inside the dahsboard after ready and loading event.

Thank you Costin :slight_smile: I will try this out tomorrow and get back to you.

1 Like

Works a treat. thank you

1 Like