Genesys CTI User Forum
Genesys CTI User Forum => Genesys CTI Technical Discussion => Topic started by: aklinbail on March 16, 2017, 05:55:35 AM
-
Hi,
My company has developed a web front-end that is intended to be used instead of GAX for external customers.
This is to provide them with limited control of GVP IVR's. (no one like the GAX interface :( )
They are providing the data in a JSON array that looks like this.
[{"node_id":"1","status":"false","message_id":"0","next_action_id":"NULL","audio_file_path":null},{"node_id":"2","status":"false","message_id":"0","next_action_id":"NULL","audio_file_path":null},{"node_id":"3","status":"true","message_id":"1","next_action_id":"test_action","audio_file_path":"http:\/\/mnlstaging.ad.busapp\/segueapps\/ivr\/uploads\/audio-messages\/Test Message(2-23-2017).mp3"}];
I am retrieving this from a webrequest block. and assigning that to a variable varWSreturn
I am trying to populate some variables which are then used to drive various decision points and pick up audio where required.
The variables are defined as user variables .. e.g. varStatus1, varStatus2, varStatus3, varAction1, varAction2,varAction3 varAudio1,varAudio2,varAudio3 e.t.c.
Here is what I have tried as Javascript
var obj = varWSreturn;
var vstatus='varStatus';
var vaction='varAction';
var vaudio='varAudio';
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
vstatus.concat(obj[key].node_id)=obj[key].status;
vaction.concat(obj[key].node_id)=obj[key].next_action_id;
vaudio.concat(obj[key].node_id)=obj[key].audio_file_path;
So I am expecting this to loop through the string and populate the variables as I have explained above..
However, it is returning nothing..
I'm not hugely versed in javascript, other than various snippets in composer... So please excuse me if I've completely screwed this..
Any suggestions will be much appreciated (even if it means using the loop block and completely different method.
Regards
Allan
-
Obj[0] wouldn't be?
Enviado de meu E6633 usando Tapatalk
-
Yes that worked.
It's not exactly what I wanted, as it means I have to specifically code in each variable e.g.
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
varAction1=obj[0].next_action_id;
varAction2=obj[1].next_action_id;
}
}
I was trying to do this dynamically, so that I can create a subroutine that works for any IVR no matter how few or many options it has..
This will do for now, but if anyone can suggest how to make this completely dynamic it would be very much appreciated.
Regards
Allan
-
Instead of actionx do an array of actions. Then you go through it doing a simple for 0 to var.length
Easier.
You need a better design at your system idea. Some software architect can help you
Enviado de meu E6633 usando Tapatalk
-
Sorry, I don't actually understand what you mean.
-
The architecture for variable number of entries in the JSON string is due to the fact this system is required by a number of different external clients with various needs.