This is an old revision of the document!


Webex Connect JavaSscript Examples

Retrieve Google Sheets worksheet- example:

Then set the response Code and Response Body as variables when leaving the HTTP node - as per below.

{
  "range": "customers!A1:Z1000",
  "majorDimension": "ROWS",
  "values": [
    [
      "PhoneNumber",
      "FirstName",
      "LastName",
      "email"
    ],
    [
      "35315551234",
      "Bob",
      "Bobster",
      "[email protected]"
    ],
    [
      "353871231234",
      "Alice",
      "Anderson",
      "[email protected]"
    ]
  ]
}
[
   {
        "PhoneNumber": "3535551234",
        "FirstName": "Bob",
        "LastName": "Bobster",
        "email": "[email protected]"
    },
    {
        "PhoneNumber": "353871231234",
        "FirstName": "Alice",
        "LastName": "Anderson",
        "email": "[email protected]"
    }	
]
if (statusCode == 200) {
    const data = JSON.parse(responseBody);
    const inputArray = data["values"];
    const headers = inputArray[0];
    const rows = inputArray.slice(1);
 
    const output = [];
    for (let i = 0; i < rows.length; i++) {
        let rowObject = {}; // Create a new object for each row - note 'const' should work here - but didn't. Platform using old JS?
        for (let j = 0; j < headers.length; j++) {
            rowObject[headers[j]] = rows[i][j];
        }
        output.push(rowObject); // Push the new object to the output array
    }
 
    myheaders = headers.toString();
    myrows = rows.toString();
    myoutput = output;
    customersJSON = JSON.stringify(output);
    1;
} else {
    2;
}
  • vendors/cisco/uc/webconnect/js.1731922895.txt.gz
  • Last modified: 2024/11/18 09:41
  • by gerardorourke