In this article
Masking String Response Parameters
Simple Single String Response parameter mask
mask.Access = ParameterAccessType.Exclusive; //This declares the mask excludes the code
{mask.Keys.Add('pie');} //Then the precode to be excluded is added
This script masks out the 'Pie' style from the list of chart styles.
A Single String parameter being masked
You can also expand this to check scenarios before implementing for example:
An advanced Single String Response parameter mask based on table cell values
//------------Parameter Scripting MASK----------------//
mask.Access = ParameterAccessType.Exclusive;
if(report.TableUtils.GetCellValue('CA',1,1).Value==0) {mask.Keys.Add('1');}
if(report.TableUtils.GetCellValue('CA',2,1).Value==0) {mask.Keys.Add('GS1');}
//The above checks table CA, row 1 column 1, row 2 column 1 to see if the value is "0" before excluding the code
A Multi String Response parameter mask
var multiResponseA : ParameterValueMultiSelect = state.Parameters["p_Country"];
//Linking the Multi parameter the the MultiSelect class
var responseA : ParameterValueResponse;
//Creating a variable to hold the selected parameter responses
var country : String = "";
//An array to hold the precodes
//checking if there are any answers in the country parameter
if(multiResponseA != null)
{
for(var x : int = 0; x < multiResponseA.Count; x++) //running a for loop to go through answers
{
responseA = multiResponseA[x];
country += "'";
country += responseA.StringValue;
country += "'";
}
}
text.Output.Append(country);//printing the selected answers to screen
The script above displays the list of corresponding cities when one or more countries are selected:
Figure 1 - A Multi String Parameter being masked.
Setting a Single String Response parameter with a fixed response
if(state.Parameters.IsNull("p_yn"))
{
state.Parameters["p_yn"] =new ParameterValueResponse("1"); //1 is yes
}In the example above, '1' is the set code for parameter 'p_yn' when the page is loaded.
Setting a Single String Response parameter with a given response from the viewer
if(!state.Parameters.IsNull("p_Gender")) //Checking if parameter is not empty
{
var Gender : String = state.Parameters.GetString("p_Gender"); //Getting the value
state.Parameters["p_Gender"] =new ParameterValueResponse(Gender); //Assigning the value
}Setting a Multi String Response parameter
if(state.Parameters.IsNull("p_Channel")){ //Check if the parameter is empty
var valArr : ParameterValue[]; //Create an array
//Create and assign values for the array
var val1 : ParameterValueResponse = new ParameterValueResponse("1");
var val2 : ParameterValueResponse = new ParameterValueResponse("2");
var val3 : ParameterValueResponse = new ParameterValueResponse("5");
valArr = [val1, val2, val3]; //assign the values to the array
// Get the value from above for populating the parameter
var multiResponse : ParameterValueMultiSelect = new ParameterValueMultiSelect(valArr);
//Set the new value
state.Parameters["p_Channel"] = multiResponse;}The script above sets several parameter values when none of the parameter values have been selected.
Figure 2 - Setting new Multi String Response parameter values
Clearing String Response Parameters
Set parameter values can be cleared via a script and a Button control.
Figure 3 - Parameter values before clearing
Clearing all parameter values on a page
if(page.SubmitSource == "Button (1)"){state.Parameters.Clear();}Figure 4 - Parameter values after clearing
Alternatively, for individual parameter clearance, a statement like the one below can be used ('p_age' is the name of the parameter to be cleared):
state.Parameters["p_Age"] = null;