@zer0 said: Hello i wanted to create a parameter where i can input multiple values where seperated by " , " is it possible? i try it under Filter and it works well but if i try it in parameter it doesnt work , any idea ? please help " params["Parameter"].split(","); "
Did you find any solution to this?? I need to do the same
@LeleTheBest said: @zer0 said: Hello i wanted to create a parameter where i can input multiple values where seperated by " , " is it possible? i try it under Filter and it works well but if i try it in parameter it doesnt work , any idea ? please help " params["Parameter"].split(","); " Did you find any solution to this?? I need to do the same
@LeleTheBest said:
Here is a way we found to do it (this goes in the beforeOpen script of the data set):
if (params["poNum"].value != null) {var newstring = params["poNum"].value var newstring2 = newstring.replace(/,/gi, "','") var newstring3 = newstring2.replace(/',' /gi, "','") this.queryText = this.queryText + " AND po.ponum in ('"+newstring3+"') ";}
Hope this helps.
@CodeRookie said: @LeleTheBest said: @zer0 said: Hello i wanted to create a parameter where i can input multiple values where seperated by " , " is it possible? i try it under Filter and it works well but if i try it in parameter it doesnt work , any idea ? please help " params["Parameter"].split(","); " Did you find any solution to this?? I need to do the same Here is a way we found to do it (this goes in the beforeOpen script of the data set): if (params["poNum"].value != null) {var newstring = params["poNum"].value var newstring2 = newstring.replace(/,/gi, "','") var newstring3 = newstring2.replace(/',' /gi, "','") this.queryText = this.queryText + " AND po.ponum in ('"+newstring3+"') ";} Hope this helps.
@CodeRookie said:
I'd like to use it as an array, i need to put it into an "IN" clause for making a query on the db.
I wrote this in the beforeOpen: ` if(params["PARAM_NAME"].value != null && params["PARAM_NAME"].value != "") { // var tempArray = params["PARAM_NAME"].split(";"); var tempArray = params["PARAM_NAME"].value.split(";");
for(var i=0; i<tempArray.length; i++) { tempArray[i]; } query = query + " AND VALUE IN (" + tempArray[0] + ", " + tempArray[1] + ", " + tempArray[2] + ", " + tempArray[3] + ", " + tempArray[4] + ", " + tempArray[5] + ", " + tempArray[6] +")";
} `
Is better to use the .value.split or only the .split? I think it's the same :-)
I need to catch the 7 values that the user can insert in a text-box as a parameter. ex. "S01;S02;S03" etc.
But, what happens if the user doesn't insert all the 7 values (string) separated by ; ?
Thanks for the help! @CodeRookie
Here's my solution:
` if(params["C_UNIT_CODE"].value != null && params["C_UNIT_CODE"].value != "") {
var tempArray = (params["C_UNIT_CODE"].value).split(";"); var str = []; query = query + " AND GT.C_UNIT_CODE IN ("; for(var i=0; i<tempArray.length; i++) { str[i] = "'" + tempArray[i] + "'"; } query = query + str.join(", "); query = query + ")";
I hope this helps!