Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Help with expression script?
DreamCoder
Hello Everyone, <br />
<br />
I am new to BIRT (surprise!) and am trying to get the hang of writing expressions. I need to create a computed column called "result" and depending on the result of several variables, this column will have a string value of either "Connected (after hours)", "Connected", "Abandon", "Abandon (after hours)",a calculated string showing connection time, or the default "Not Connected"<br />
<br />
Here is the script I am trying to use:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if (typeof(row["session_id"]) == "number" && row["open_rule"] == 0)
"Connected (after hours)";
else if (typeOf(row["session_id"]) == "number" && row["open_rule"] == 1)
"Connected";
else if (row["term_party"] == "CALLER" && row["open_rule"] == 1 || row["open_rule"] == "")
"Abandon";
else if (row["term_party"] == "CALLER" && row["open_rule"] == 0)
"Abandon (after hours)";
else if (row["term_pary"] == "SYSTEM" && row["dial_disposition"] != "")
row["dial_disposition"] & "(" & row["dial_duration"] & " sec.)";
else
"Not Connected";
</pre>
<br />
Any help would be awesome!<br />
<br />
Thanks,<br />
Amanda
Find more posts tagged with
Comments
mwilliams
Hi Amanda,
What is your script currently giving you?
DreamCoder
Hi Michael,<br />
<br />
Here is the error I am receiving:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
A BIRT exception occurred.
Plug-in Provider:Eclipse.org
Plug-in Name:BIRT Data Engine
Plug-in ID:org.eclipse.birt.data
Version:2.3.2.r232_v20090211
Error Code:data.engine.CompCol.FailRetrieveValueComputedColumn
Error Message:Fail to compute value for computed column "result".
A BIRT exception occurred: There are errors evaluating script "if (typeof(row["session_id"]) == "number" && row["open_rule"] == 0)
"Connected (after hours)";
else if (typeOf(row["session_id"]) == "number" && row["open_rule"] == 1)
"Connected";
else if (row["term_party"] == "CALLER" && row["open_rule"] == 1 || row["open_rule"] == "")
"Abandon";
else if (row["term_party"] == "CALLER" && row["open_rule"] == 0)
"Abandon (after hours)";
else if (row["term_pary"] == "SYSTEM" && row["dial_disposition"] != "")
row["dial_disposition"] & "(" & row["dial_duration"] & " sec.)";
else
"Not Connected";":
ReferenceError: "typeOf" is not defined. (<inline>#3).. See next exception for more information.
There are errors evaluating script "if (typeof(row["session_id"]) == "number" && row["open_rule"] == 0)
"Connected (after hours)";
else if (typeOf(row["session_id"]) == "number" && row["open_rule"] == 1)
"Connected";
else if (row["term_party"] == "CALLER" && row["open_rule"] == 1 || row["open_rule"] == "")
"Abandon";
else if (row["term_party"] == "CALLER" && row["open_rule"] == 0)
"Abandon (after hours)";
else if (row["term_pary"] == "SYSTEM" && row["dial_disposition"] != "")
row["dial_disposition"] & "(" & row["dial_duration"] & " sec.)";
else
"Not Connected";":
ReferenceError: "typeOf" is not defined. (<inline>#3).
</pre>
<br />
It doesn't appear to like "typeOf" which is a javascript function. Basically, what I am trying to do is figure out if row["session_id"] is a number or a string. Do you know of a way I can successfully do this in birt?<br />
<br />
Thanks, <br />
Amanda
bhanley
I am not sure if <em class='bbc'>typeOf(...)</em> is valid. I do not that you can check for number using <em class='bbc'><strong class='bbc'>isNaN(...)</strong></em>. Try this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if (!(isNan(row["session_id"])) && row["open_rule"] == 0)
"Connected (after hours)";
else if (!(isNaN(row["session_id"])) && row["open_rule"] == 1)
"Connected";
else if (row["term_party"] == "CALLER" && row["open_rule"] == 1 || row["open_rule"] == "")
"Abandon";
else if (row["term_party"] == "CALLER" && row["open_rule"] == 0)
"Abandon (after hours)";
else if (row["term_pary"] == "SYSTEM" && row["dial_disposition"] != "")
row["dial_disposition"] & "(" & row["dial_duration"] & " sec.)";
else
"Not Connected";</pre>
DreamCoder
Hi Brian, <br />
<br />
Thanks for your response. I tried your code and got the following error:<br />
<br />
<strong class='bbc'>ReferenceError: "isNan" is not defined. (<inline>#1).</strong><br />
<br />
Thanks,<br />
Amanda
DreamCoder
<blockquote class='ipsBlockquote' data-author="DreamCoder"><p>Hi Brian, <br />
<br />
Thanks for your response. I tried your code and got the following error:<br />
<br />
<strong class='bbc'>ReferenceError: "isNan" is not defined. (<inline>#1).</strong><br />
<br />
Thanks,<br />
Amanda</p></blockquote>
<br />
Nevermind, I figured it out...just a typo in the code. Its running, tho its not giving me the values I expect so I'll have to troubleshoot some of my logic. <br />
<br />
Thanks for your help!<br />
Amanda
DreamCoder
Hi All, Just wanted to post what my final code looked like. Works like a charm. Thank you to Brian for the assistance:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if (!(isNaN(row["session_id"])) && row["open_rule"] == 0)
"Connected (after hours)";
else if (!(isNaN(row["session_id"])) && row["open_rule"] == 1)
"Connected";
else if (row["term_party"] == "CALLER" && row["open_rule"] == 1 || row["open_rule"] == "")
"Abandon";
else if (row["term_party"] == "CALLER" && row["open_rule"] == 0)
"Abandon (after hours)";
else if (row["term_party"] == "SYSTEM" && row["dial_disposition"] != null)
row["dial_disposition"] + "(" + row["dial_duration"] + " sec.)";
else
"Not Connected";
</pre>