cancel
Showing results for 
Search instead for 
Did you mean: 

SAC story page filter default selection with Button Script

RameshBandi
Explorer
0 Kudos
1,068

Hi Experts,

We have a scenario for one our story where we would like to filter only on Version with Property ( Start_Period) which has date values in it.

Example: Version Dimension

 

RameshBandi_0-1721244336984.png

 

 

We have story which we need to display with the only column with:

 

RameshBandi_1-1721244336986.png

 

We are trying to fix story filter with Date and Version Property (Start_Period) and getting an error while running the button with the below script.

var selections = Table_1.getDataSource().getDataSelections();
var member = PlanningModel_1.getMember("Version",selections[0]["Version"]);
var prop = member.properties;
var planning = Table_1.getPlanning();
var SM1 = prop["Start_Period"];
var dateparam = "[Date].[FYP].&[" +SM1+ "]";

 

//Table_1.getDataSource().setDimensionFilter("Date","[Date].[FYP].&[202401]");
Table_1.getDataSource().setDimensionFilter("Date",dateparam);

 

There are no errors in script, however when we run Button it throws an error as below:

RameshBandi_2-1721244336987.png

 

Please advise.

Regards,

Ram

Accepted Solutions (0)

Answers (2)

Answers (2)

MichalCK
Participant
0 Kudos

try to add an InputControl selector with Version to your page and use following code

 

var selected_version = InputControl_1.getInputControlDataSource().getActiveSelectedMembersWithUnbooked().values().next().value.id;
var ver = PlanningModel_1.getMember("Version", selected_version);
if (ver){
	if (ver.properties.Start_Period){
	var dateparam = "[Date].[FYP].&[" +ver.properties.Start_Period + "]";
	Table_1.getDataSource().setDimensionFilter("Date",dateparam);
	}
}

 

david3030
Explorer
0 Kudos

Hello,

Could you please send in the console those informations to check what's wrong ?

console.log(selections);

console.log(member);

console.log(prop);

console.log(dateparam);

Put these lines bevore the line with setdimensionfilter. Then, go in Devtool (F12) and give a printscreen of what the console.log returns in the Information register of the console

 

Regards

RameshBandi
Explorer
0 Kudos

Hi David,

Thanks for the Reply! As suggested I did put Console parameters in my code and captured Developer Tools logs. Please see the screenshot.

 

RameshBandi_0-1721311311358.png

 

Regards,

Ramesh

 

 

david3030
Explorer
0 Kudos
Hello, put this line : console.log(selections); after the first line where you declare var selections. You will see as far as I think that selection is undefinded because there is no result in you table. i think