Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to reference the string of a multi-value parameter
ArmorOfGod
<p>I'm working on a report that has a different title depending on which parameter is selected. I need to add a new condition that will display a unique title if specific values are selected from TWO different parameters. Here's what I have:</p>
<pre class="_prettyXprint _lang-js">
<VALUE-OF>if (params["Categories"] == "F-MAC" and params["WorkCodes"] != "ALL")
{
"Furniture and Design"
}
else
{
if (params["Categories"] == "F-MAC")
{
"Move-Add-Change"
}
else
{
if (params["Categories"] == "F-DAMAGE")
{
"Damage"
}
else
{
if (params["Categories"] == "F-DISASTER")
{
"Disaster"
}
else
{
if (params["Categories"] == "F-PMB")
{
"Preventive Maintenance"
}
}
}
}
}
</VALUE-OF> Billing Report
</pre>
<p>The first line is the one I'm having the problem with. The "!= All" is just a placeholder. <strong>What I actually want to do is use "Furniture and Design" as the title when "F-MAC" is selected as the Category and both DESIGN and FURN are selected for the multi-value parameter WorkCodes. </strong></p>
<p> </p>
<p>I guess my question is, how would I code that? What exactly would the value of params["WorkCodes"] look like when both DESIGN and FURN are selected? Would it be "DESIGN,FURN"? Something else? Or is it not even possible to do this?</p>
<p> </p>
<p>Also, for some reason it's not even working when I try != "All". Can you not reference two params in the same line like that? Or did I mess something up somewhere? Any help would be appreciated.</p>
Find more posts tagged with
Comments
Chad Montgomery
<p>It looks like you are using a text object with HTML formatting, is that correct? If you aren't already, try using the Dynamic Text object located in the Palette. In there you'll use the expression builder to create your code.</p>
<pre class="_prettyXprint _lang-">
if (params["Categories"] == "F-MAC" && params["WorkCodes"] != "ALL")
</pre>
<p>The code above is the correct first line of code. As you can see, the "&&" is the correct way to use the AND operator, "and" doesn't work. Also, <VALUE-OF> is not necessary when using the Dynamic Text object, as it's not HTML-based. Try fixing that first line and taking out the <VALUE-OF> element.</p>
<p> </p>
<p>As for the Billing Report at the very end, I'm not really sure what you're attempting there. Are you trying to concatenate on the title such as "Furniture and Design Billing Report"?</p>
micajblock
<p>Also multi-select parameters are arrays.</p>
ArmorOfGod
<blockquote class="ipsBlockquote" data-author="cmonty" data-cid="139956" data-time="1446241226">
<div>
<p>It looks like you are using a text object with HTML formatting, is that correct? If you aren't already, try using the Dynamic Text object located in the Palette. In there you'll use the expression builder to create your code.</p>
<pre class="_prettyXprint _lang-">
if (params["Categories"] == "F-MAC" && params["WorkCodes"] != "ALL")
</pre>
<p>The code above is the correct first line of code. As you can see, the "&&" is the correct way to use the AND operator, "and" doesn't work. Also, <VALUE-OF> is not necessary when using the Dynamic Text object, as it's not HTML-based. Try fixing that first line and taking out the <VALUE-OF> element.</p>
<p> </p>
<p>As for the Billing Report at the very end, I'm not really sure what you're attempting there. Are you trying to concatenate on the title such as "Furniture and Design Billing Report"?</p>
</div>
</blockquote>
<p> </p>
<p>Ah, I can't believe I missed that. I switched and to && and it works fine now. Thanks!</p>
<p> </p>
<p>Yes, text object with HTML formatting. I switched to Dynamic Text and took out <VALUE OF> as you suggested, but now it just displays the full block of code in the header. I moved "Billing Report" to the end of each string, instead of having it concatenate at the end, but I'm still not sure how to get rid of <VALUE OF>. That's not a big deal to me though as long as it works.</p>
<p> </p>
<p>Now that we got the error figured out, <strong>I want to get rid of the != "ALL" part and instead, I want the condition to be that both DESIGN and FURN were selected. So basically, when F-MAC is selected for Categories and both DESIGN and FURN are selected for WorkCodes, it should display a unique title. Otherwise, it's just based on the Category selected. How do I check the WorkCodes parameter to see if both values were selected?</strong> I see mblock mentioned multi-select parameters are arrays but I'm not sure how to go about checking an array for two values.</p>
<p> </p>
<p>Updated code:</p>
<pre class="_prettyXprint _lang-js">
<VALUE-OF>if (params["Categories"] == "F-MAC" && params["WorkCodes"] != "ALL")
{
"Furniture and Design Billing Report"
}
else
{
if (params["Categories"] == "F-MAC")
{
"Move-Add-Change Billing Report"
}
else
{
if (params["Categories"] == "F-DAMAGE")
{
"Damage Billing Report"
}
else
{
if (params["Categories"] == "F-DISASTER")
{
"Disaster Billing Report"
}
else
{
if (params["Categories"] == "F-PMB")
{
"Preventive Maintenance Billing Report"
}
}
}
}
}</VALUE-OF>
</pre>
Matthew L.
<p>I think there might be some confusion on the requirements of this question.</p>
<p>Multi-value/select parameters are arrays like mblock indicated in the previous post.</p>
<p>Looking through the example code you provided, it looks like your not using multi-value parameters but rather multiple parameters (more than 1 parameter) that could have different values depending on the user input.</p>
<p> </p>
<p>Also looking through the example code, it seems you are using (or wanting to use) a Text element with a contentType of HTML (based on the <VALUE-OF> tags).</p>
<p>Attached is an example based on your original logic that uses a Text element with a contentType of HTML using multiple parameters.</p>
<p>I've also made the WorkCodes parameter Multi-Value as I believe this is what you are wanting to accomplish as an end result.</p>
<p> </p>
<p>Please look over the attached example for reference.</p>
<p> </p>
<p>Modified code from original post:</p>
<pre class="_prettyXprint _lang-html">
<div id="MyDivReference"></div> <!--Reference div for output display -->
<script type="text/javascript">
var div = document.getElementById("MyDivReference"); //Get reference div tag
var outputText = "";
var categories = "<VALUE-OF>params["Categories"].value</VALUE-OF>";
var workCodes = "<VALUE-OF>params["WorkCodes"].toString()</VALUE-OF>" //Set toString()
if( categories == "F-MAC" && (workCodes.indexOf("DESIGN")>-1 && workCodes.indexOf("FURN")>-1) ){
outputText = "Furniture and Design";
}else if( categories == "F-MAC" ){
outputText = "Move-Add-Change";
}else if( categories == "F-DAMAGE" ){
outputText = "Damage";
}else if( categories == "F-DISASTER" ){
outputText = "Disaster";
}else if( categories == "F-PMB" ){
outputText = "Preventive Maintenance";
}
div.innerHTML = outputText + " Billing Report"; //Send new converted href string to the div tag
</script>
</pre>
Chad Montgomery
<p>Matthew is correct regarding the if statement he has, it just needs to be altered if you're not wanting to use HTML:</p>
<pre class="_prettyXprint _lang-">
if(params["Categories"] == "F-MAC" &&
params["WorkCodes"].toString().indexOf("DESIGN")>-1 &&
params["WorkCodes"].toString().indexOf("FURN")>-1)
</pre>
<p>You should just be able to delete the <VALUE-OF> and </VALUE-OF> portions, are you saying you're running into an error when you try to delete them?</p>
ArmorOfGod
<blockquote class="ipsBlockquote" data-author="Matthew L." data-cid="139991" data-time="1446482624">
<div>
<p> </p>
<p>I think there might be some confusion on the requirements of this question.</p>
<p>Multi-value/select parameters are arrays like mblock indicated in the previous post.</p>
<p>Looking through the example code you provided, it looks like your not using multi-value parameters but rather multiple parameters (more than 1 parameter) that could have different values depending on the user input.</p>
<p> </p>
<p>Also looking through the example code, it seems you are using (or wanting to use) a Text element with a contentType of HTML (based on the <VALUE-OF> tags).</p>
<p>Attached is an example based on your original logic that uses a Text element with a contentType of HTML using multiple parameters.</p>
<p>I've also made the WorkCodes parameter Multi-Value as I believe this is what you are wanting to accomplish as an end result.</p>
<p> </p>
<p>Please look over the attached example for reference.</p>
<p> </p>
<p>Modified code from original post:</p>
<pre class="_prettyXprint _lang-html">
<div id="MyDivReference"></div> <!--Reference div for output display -->
<script type="text/javascript">
var div = document.getElementById("MyDivReference"); //Get reference div tag
var outputText = "";
var categories = "<VALUE-OF>params["Categories"].value</VALUE-OF>";
var workCodes = "<VALUE-OF>params["WorkCodes"].toString()</VALUE-OF>" //Set toString()
if( categories == "F-MAC" && (workCodes.indexOf("DESIGN")>-1 && workCodes.indexOf("FURN")>-1) ){
outputText = "Furniture and Design";
}else if( categories == "F-MAC" ){
outputText = "Move-Add-Change";
}else if( categories == "F-DAMAGE" ){
outputText = "Damage";
}else if( categories == "F-DISASTER" ){
outputText = "Disaster";
}else if( categories == "F-PMB" ){
outputText = "Preventive Maintenance";
}
div.innerHTML = outputText + " Billing Report"; //Send new converted href string to the div tag
</script>
</pre>
</div>
</blockquote>
<p> </p>
<p>Sorry if I've not been clear, I'm a novice at this stuff but I'm trying to learn
</p>
<p> </p>
<p>The report does use multiple parameters, of which 1 is called "Categories" and another is called "WorkCodes". WorkCodes is a multi-value parameter, they can hold control to select more than 1 value from the list. I hope that clears it up.</p>
<p> </p>
<p>It is a Text element. Originally, it was set to HTML and "Formatting". I changed "Formatting" to "Dynamic Text", although I'm not sure what that really changed.</p>
<p> </p>
<p>I really appreciate you taking the time to post. Cmonty's revision to your post worked for me so I went with that.</p>
<p> </p>
<p> </p>
<blockquote class="ipsBlockquote" data-author="cmonty" data-cid="139993" data-time="1446483726">
<div>
<p>Matthew is correct regarding the if statement he has, it just needs to be altered if you're not wanting to use HTML:</p>
<pre class="_prettyXprint _lang-">
if(params["Categories"] == "F-MAC" &&
params["WorkCodes"].toString().indexOf("DESIGN")>-1 &&
params["WorkCodes"].toString().indexOf("FURN")>-1)
</pre>
<p>You should just be able to delete the <VALUE-OF> and </VALUE-OF> portions, are you saying you're running into an error when you try to delete them?</p>
</div>
</blockquote>
<p> </p>
<p>This worked perfectly, thank you!<br><br>
Yes, when I removed the <VALUE OF> portions, it just put the entire block of text of my code in the header as the title.</p>
<p> </p>
<p>So should I change this to "Auto" or "Plain" if I'm not using HTML?</p>
Chad Montgomery
<p>You're using the wrong object. You need to select Dynamic Text from the palette, not in the drop down inside the Text object. Inside the Dynamic Text object, it will be an expression builder, you won't need the <VALUE-OF> there, the layout will still show all the code, but when you run it, it will have your header displayed properly.</p>
<p><img src="
http://i.imgur.com/SsF4XXI.jpg"
; alt="SsF4XXI.jpg"></p>