Picture of Felix 2874
Registered 9 years 9 days
Felix 2874 Friday, 19 April 2024, 03:01 PM
calllistApi minus in variable name causes issues
Hi,

if I'm using the calllistApi and gets an update form it is causes an issue with the minus in the var name for example
call-duration
I'm using this code to debug in incoming messages;
calllistApi.onmessage.attach(function (sender, obj) {
if (obj.msg.mt == "Update") {
console.log("calllistApi_onmessage: " + obj.msg.entries[0].time);
console.log("calllistApi_onmessage: " + obj.msg.entries[0].call-duration);//mach probleme wegen dem - im Namen

}
});

but the minus in call-duration will be interpreted as an minus sign for calculation and gives me this error:
Uncaught ReferenceError: duration is not defined
the time name works just fine.

Any Idea?
Andreas Fink
Moderator Registered 13 years 109 days
Andreas Fink (innovaphone) Friday, 19 April 2024, 08:01 PM
Re: calllistApi minus in variable name causes issues
Hello Felix,

it should be possible to access this property from JavaScript with the bracket notation:

obj.msg.entries[0]["call-duration"]

Best Reagrds
Andreas Fink
Picture of Felix 2874
Registered 9 years 9 days
Felix 2874 Friday, 19 April 2024, 03:29 PM
Re: calllistApi minus in variable name causes issues
Hi Andreas,

thanks for your answer.
This gives me this error

Uncaught SyntaxError: missing name after . operator
but removing the . solves the issue
obj.msg.entries[0]["call-duration"]
Andreas Fink
Moderator Registered 13 years 109 days
Andreas Fink (innovaphone) Friday, 19 April 2024, 08:00 PM
Re: calllistApi minus in variable name causes issues
Thank you! The period should not be there - fixed it in the original answer.

Best Regards
Andreas Fink
← You can define your color theme preference here