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)
Javascript String functions not working
Charles Paluda
<p>Hi, I'm trying to use the charCodeAt() function from BIRT's Javscript String Functions in the Palette. I keep getting the error "TypeError: Cannot find function chareCodeAt in object 244004385"</p><p> </p><p>244004385 is the value of an integer parameter that is passed in to the report. I'm trying to use that in some Javascript code where I need to get the ascii code values of each character and add them up. Strangely if I run "charAt()" instead which is supposed to return the actual character that actually works except that it's return the code I'm after. I.e. index 0 gives me 50 instead of 2, or index 1 gives me 52 instead of 4. Here's a snippet of the code I'm using. I've tried using both the actual parameter (dragged in from the palette) or in the case of the first line below a page variable where I took the parameter and assigned it to the page variable with "params["ca_blockId"].value.toString()" in expression builder for the page variable.</p><p> </p><div><pre class="_prettyXprint">blockId = vars["pv_ca_blockId"];blockIdLength = BirtStr.charLength(blockId);currentPosition = 0;stringToNum = 0;while (currentPosition < blockIdLength){ stringToNum = blockId.charCodeAt(currentPosition) - 48; currentSum += stringToNum; currentPosition++;}</pre></div><p> </p>
Find more posts tagged with
Comments
Charles Paluda
<p>Ok nevermind I got it to work finally. so the page variable was not working, not sure maybe I will try a report variable for kicks, but I actually got it to work with the report parameter instead. When I first tried using the parameter and dragged it over it formatted it as [color=rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;]"params["ca_blockId"].value" which was not working. Replacing it with [/color][color=rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;]"params["ca_blockId"].toString()" fixes the problem all the way through.[/color]</p>