Author Topic: Javascript Routing - Empty message-Object  (Read 12567 times)

asymetrixs

  • Administrator
  • Newbie
  • *****
  • Posts: 47
    • View Profile
Javascript Routing - Empty message-Object
« on: January 09, 2013, 04:30:37 PM »
Hi,

I just wrote a simple routing script in Javascript and I have the following problem:

Code: [Select]
message.callto_account = mysqlAccount; // Setting the MySQL Account (this is a variable containing a string)
message.callto_query = "CALL yate_voice_timeout('" + dbTimeout + "', '" + language + "')"; // Setting up the query
Engine.output("1) ME: " + message.caller); // Gives: 123456
Channel.callTo("dbwave/play//backup.au"); // Plays the Binary Data returned by the SQL Query
Engine.output("2) ME: " + message.caller); // Gives: (empty)
...
message.callto.1  = "sip/sip:999@abc.com";
message.callto.2  = "sip/sip:888@xyz.org";
Channel.callJust("fork");

When issuing the callJust, then message.caller is empty which causes problems because the value in CDR insert/update/finalize is empty too.
As far as described in the docs, that behavior is correct, because the return values of Channel.callTo are written in the message object, but I want to call other targets as well.

So do I have to copy all parameters and store them in separate variables to reuse them or is there a way to retrieve the original 'incoming'-message with all its values?

Regards,
Damian / asymetrixs

asymetrixs

  • Administrator
  • Newbie
  • *****
  • Posts: 47
    • View Profile
Re: Javascript Routing - Empty message-Object
« Reply #1 on: January 10, 2013, 08:22:28 AM »
Ok, as talked to Paul the answer is:

All parameters in the message object have to be copied and preserved in variables because they are overwritten in Channel.callTo().