jscript example from work

Welcome to Siddharth, Mae, Bao-An, Ryan, Sitra, Hoyong, and Janet, who meet Mondays and Wednesdays, (but no class on January 21st ) in January of 2019 at Collin College, the courtyard campus to learn how to READ JavaScript code -- plus we learn some programming. JavaScript forms the basic Language of the web; it's the glue between the HTML and CSS actions that form the Transformation in a browser or API call.
Post Reply
maechoi
Posts: 6
Joined: Wed Jan 09, 2019 6:39 pm

jscript example from work

Post by maechoi » Tue Jan 29, 2019 8:47 am

/********** Parameter use in Reports **********/

/*To check one of the parameters in report script, simply call the Event.Parameter object and search the collection
* for the exact string name of the parameter
*Parameter values and how to use and interperet them are dependent on the "Type" of the parameter
*/

/***** Parameter Type : Date *****/
var start = DateTime.Parse(Event.Parameters["StartDate"]);
var end = DateTime.Parse(Event.Parameters["EndDate"]);
//otherDate variable can be set to whatever important date for comparing, such as coverage effective date or termination
var otherDate = DateTime.Today;

//Check if other date is within the Report Period parameters
if(start <= otherDate && otherDate <= end)
{
//Do something
}

/***** Parameter Type : String *****/
//String parameters just return strings, once you have the value, you can modify/check it is needed like any other string
var myParam = Event.Parameters["ParameterName"];
Event.Value = myParam;

/***** Parameter Type : ComboBox *****/
//Combo box allows multiple values, but only one can be selected
// Label | Value
// Choice 1|100
// Choice 2|Three
// Choice 3|False
//The parameter will return the Value side chosen, and return it as a string
//Add an if check to see that the object is not Null/Undefined before using typically
var myChoice = Event.Parameters["ComboChoice"];
if(myChoice)
{
Event.Value = myParam; //Will be either "100", "Three", or "False"
}
else
{
Event.Value = "Blank Choice Selected";
}

/***** Parameter Type : CheckList *****/
//CheckList works similar in setup to ComboBox to create the parameter, however the value of the parameter is a collection
// of the values by name; if it is not in the collection, then the value was not checked
// Label | Value
// All|All
// Choice 1|100
// Choice 2|Three
// Choice 3|False
//Test if null to find if the list is empty
var myList = Event.Parameters["ListOfChoices"];
var myStr = "You selected: ";
if(myList)
{
if(myList.Contains("All"))
{
myStr+= "Everything!";
}
else
{
for(var check in myList)
{
if(check == "False")
myStr+= " *Compare to value* "
myStr+= check +" :";
}
}
}
else
{
myStr+= "None!";
}

Event.Value = myStr;

/***** Parameter Type : TextBoxList *****/
//TextBoxList creates a dictionary of the values, a dictionary is searched by a key value and returns the input value, so
// the values set on the parameter are now the keys and the dictionary is always at least an empty string so no need to
// check for a null parameter; instead you can check if the value for that key is empty
// Label | Value
// All|All
// Choice 1|100
// Choice 2|Three
// Choice 3|False
//Get all the values entered in the parameter
var myDict = Event.Parameters["TextBoxDict"];
var myStr = "You entered: ";

if(myDict["All"])
myStr+= "All = " + myDict["All"] +" -> ";

for(var check in myDict)
{
if(myDict[check.Key])
myStr+= check.Key +" = "+ myDict[check.Key] +" :";
}

Event.Value = myStr;



Post Reply