02-15-2019 09:56 AM
Using the Set Value element I set the below.
But even when I tried the toString() the value of the local variable is a float (in this example) I add 20 + 7 and get 27.0
I need to get the value "27" - and not "27.0" - any ideas on how this might be possible?
var a = (parseInt({Data.Session.ClosedTypeInt},10));
var b = (parseInt({Data.Element.10_Option_OptionEnable.value},10));
var c = a+b;
var str = c.toString();
eval (str);
---- Output from Log shows the value as a float ----
custom,Data.Element.10_Option_OptionEnable.value,7
custom,Data.Session.ClosedTypeInt, 20
custom,LocalVar.NewClosed1,27.0
Regards,
Gerry
Solved! Go to Solution.
02-27-2019 07:56 AM
The way I do this is to use .toFixed(0);
In my queue scripts, I check for calls in queue to let the caller know where they are in the queue. I have to add one then convert it to an integer using a Set Value element so it plays properly using Say It Smart. I do it like this:
var callsInQueue;
var ciq = {Data.Session.callsInQueue};
callsInQueue = (parseInt(ciq) + 1).toFixed(0);
I don't know if this is technically correct but it was the only way I could eliminate the .0 at the end of the value.
This returns an integer value rather than the float value.
I hope this helps.
02-15-2019 10:42 AM
This is just a javascript problem, right?
Have you tried something like:
var str = "" + c;
OR
var str = String(c);
02-15-2019 01:31 PM
Math.floor(c) if you want a whole number.
String(Math.floor(c)) if you want it as a string.
02-18-2019 01:51 AM
Thanks Paul, thanks Quigath,
None of these work.
The var str = "" + c;
should work.
But even if you concatenate a number.
var c = 14;
var str = "1" + c;
This evaluates to 114.0 and not 114
No matter what I do - the value stays as a number and does not convert to a string.
I try a little Java class.
Gerry
02-27-2019 07:56 AM
The way I do this is to use .toFixed(0);
In my queue scripts, I check for calls in queue to let the caller know where they are in the queue. I have to add one then convert it to an integer using a Set Value element so it plays properly using Say It Smart. I do it like this:
var callsInQueue;
var ciq = {Data.Session.callsInQueue};
callsInQueue = (parseInt(ciq) + 1).toFixed(0);
I don't know if this is technically correct but it was the only way I could eliminate the .0 at the end of the value.
This returns an integer value rather than the float value.
I hope this helps.
02-27-2019 08:56 AM
Bill,
That was exactly my problem (or very similar) - thanks a mil.
That is better than my approach and what I was looking for.
Gerry
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide