Script Variables | Type | Array |
Dim_array | String | X |
Hier_array | String | X |
ModelID | String | |
Opt_array | String | X |
OverallCount | Integer | |
PageID | String | |
StoryID | String | |
Unbooked_array | String | X |
URLParam_filters | String | |
URLParam_Variables | String | |
Val_array | String | X |
function ReportIDMapping(ButtonCall: String): void
//function maps the story, model and page ID based on the button name
switch(ButtonCall)
{
case "Resource Planning":
StoryID = <StoryID>;
ModelID = <ModelID>;
PageID = <PageID>;
break;
case "Simulate Depreciation":
<<add your parameters here>>
}
Utils.openReceiverApp(StoryID, ModelID, PageID);
function openReceiverApp(StoryID: String, ModelID: string, PageID: string): void
//function executes the URL
var ds = Table.getDataSource();
var separator = "|";
Dim_array = [""];
Hier_array = [""];
Opt_array = [""];
Val_array = [""];
OverallCount = 0;
Unbooked_array = [""];
UrlParam_Filters ="";
UrlParam_Variables = "";
Utils.getUrlParam_Filters(ds);
//if any selection is performed
if (OverallCount > 0)
{
var urlparam = UrlParameter.create("f01Model",ModelID);
var url_array = [urlparam];
//dimension array
for (var i = 0; i < Dim_array.length; i++) {
var val_values = Dim_array[i].split(separator);
//console.log(["urlarray1",val_values,]);
urlparam = UrlParameter.create(val_values[0],val_values[1]);
url_array.push(urlparam);
}
//opt array
for (i = 0; i < Opt_array.length; i++) {
val_values = Opt_array[i].split(separator);
urlparam = UrlParameter.create(val_values[0],val_values[1]);
url_array.push(urlparam);
}
//values array
for (i = 0; i < Val_array.length; i++) {
val_values = Val_array[i].split(separator);
//console.log(["urlarray3",val_values,]);
urlparam = UrlParameter.create(val_values[0],"["+val_values[1]+"]");
url_array.push(urlparam);
}
//hierarchy array
for (i = 0; i < Hier_array.length; i++) {
val_values = Hier_array[i].split(separator);
//console.log(["urlarray3",val_values,]);
urlparam = UrlParameter.create(val_values[0],val_values[1]);
url_array.push(urlparam);
}
//unbooked array
for (i = 0; i < Unbooked_array.length; i++) {
val_values = Unbooked_array[i].split(separator);
//console.log(["urlarray3",val_values,]);
urlparam = UrlParameter.create(val_values[0],val_values[1]);
url_array.push(urlparam);
}
}
NavigationUtils.openStory(StoryId,PageID,url_array, true);
function getURLParam_Filters(ds: datasource): void
// function loops through dimension filters and execute
var dimensions = ds.getDimensions();
for (var i=0;i<dimensions.length; i++){
//get dimension
var dimension = dimensions[i];
//get dimensionfilters
var filters = ds.getDimensionFilters(dimension);
// check filter values and if Measure is filtered
if (filters.length > 0 && dimension.id !== "@MeasureDimension") {
//console.log(["Filters", filters,]);
var hierarchy = ds.getHierarchy(dimension).id;
//get filter function
Utils.getFilter(dimension.id,filters,hierarchy,i);
}
}
function getFilter(dimension: string, filters: FilterValue[], hierarchy: string, dimindex: integer): void
//Function populates Dim, Hier, Opt and Val arrays
var s = "";
var v_separator = "|";
var v_dim = "";
var v_opt = "";
var v_hier = "";
var v_unbooked = "";
var v_optvalue = "in";
// count required for parameters
if ( filters.length > 0 )
{
OverallCount = OverallCount + 1;
}
for (var i = 0; i < filters.length; i++) {
var filter = filters[i];
// create variable to store dimension parameters for URL
var v_str = ConvertUtils.numberToString(OverallCount);
//dimension parameters
v_dim = "f0" + v_str + "Dim";
Dim_array.push(v_dim + v_separator + dimension);
//hierarchy parameters
v_hier = "f0" + v_str + "Hierarchy";
Hier_array.push(v_hier + v_separator + hierarchy);
//unbooked parameters
v_unbooked = "f0" + v_str + "Unbooked";
Unbooked_array.push(v_unbooked + v_separator + "true");
if (filter.type === FilterValueType.Single) {
// handle single filter value
var singleFilter = cast(Type.SingleFilterValue, filter);
//opt parameters
if (singleFilter.exclude === true)
{
v_optvalue = "notIn";
} else
{
v_optvalue = "in";
}
v_opt = "f0" + v_str + "Op";
Opt_array.push(v_opt + v_separator + v_optvalue);
if (hierarchy !== "@FlatHierarchy")
{
//split values
var v_trim = singleFilter.value.split("[").join("");
v_trim = v_trim.split("]").join("");
v_trim = v_trim.split("&").join("");
if (dimension === "Date") //Date comes in a different structure
{
var array = v_trim.split(".");
s = s + '"' + array[4] + '"';
}else
{
array = v_trim.split(".");
s = s + '"' + array[2] + '"';
}
} else
{
s = s + '"' + singleFilter.value + '"';
}
} else if (filter.type === FilterValueType.Multiple) {
// handle multiple filter value
var multipleFilter = cast(Type.MultipleFilterValue, filter);
var values = multipleFilter.values;
//opt parameters
if (multipleFilter.exclude === true)
{
v_optvalue = "notIn";
} else
{
v_optvalue = "in";
}
v_opt = "f0" + v_str + "Op";
Opt_array.push(v_opt + v_separator + v_optvalue);
for (var j = 0; j < values.length; j++) {
if (j > 0) {
s = s + ",";
}
// check hierarchy selection
if (hierarchy !== "@FlatHierarchy")
{
//split values
v_trim = values[j].split("[").join("");
v_trim = v_trim.split("]").join("");
v_trim = v_trim.split("&").join("");
if (dimension === "Date") //Date comes in a different structure
{
array = v_trim.split(".");
s = s + '"' + array[4] + '"';
}else
{
array = v_trim.split(".");
s = s + '"' + array[2] + '"';
}
} else //flat presentation
{
s = s + '"' + values[j] + '"';
}
}
}
Val_array.push("f0" + v_str + "Val" + v_separator + s);
}
//if you want to print the arrays
//console.log(["val_array",Val_array,]);
//console.log(["Dim_array",Dim_array,]);
//console.log(["opt_array",Opt_array,]);
//console.log(["Hier_array",Hier_array,]);
Step 5: Create a button
function OnClick() void
Utils.ReportIDMapping(ResourcePlanning.getText());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |