• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Possible bug with Scripting data source editor

    User help
    2
    7
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      iperry
      last edited by iperry

      Hey guys,

      I am using a scripting data source to prototype code for adding data points and I am encountering an annoying/challenging behaviour in the editor. It appears that when the script is loaded, all code after the "<" in the "for" condition is being chopped off.

      For example, if I have the script:
      0_1551893434890_7ec54e16-006c-4397-9ab1-e09ca8fbab1e-image.png

      I can create, save, and validate the script without issues. However, if I click to another data source and then return, all the code after the "<" is gone:
      0_1551893608176_04ed8cd7-5785-4545-9742-0c8754c6e36b-image.png

      The same behaviour occurs even if the for loop is commented:
      0_1551893796263_59da8c5c-9eb6-466a-b54a-68ea957cb99b-image.png

      This behavior occurs both in Chrome and Firefox. I have also restarted the browser and server without any success.

      If you need any further details, just let me know.

      Thanks
      Ian

      Edit: I am not seeing any errors in the logs files or dev console.

      Edit: where the "<" is in the code does not matter. If I add the character anywhere in the code, it gets chopped at that point:
      0_1551894920384_6f06dccd-4c06-4c4c-9c11-99fbf9d6b06c-image.png

      PS: I don't see the log file being produced (or written) to if I have a log statement in the code:
      0_1551895748294_1c63b29c-0c29-4961-96db-806133db0f73-image.png

      The log file is not in the directory indicated. Perhaps there is a difference in logging if I validate/run the script versus it running automatically via the cron or context point.

      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by

        Hi Ian,

        I can assure you that the < sign can appear in scripts. It's a pretty common symbol! I was not able to readily reproduce...

        What version of Mango and the Scripting module are you using?

        Perhaps there is a difference in logging if I validate/run the script versus it running automatically via the cron or context poin

        Yes there is. It only actually logs to the file at runtime.

        1 Reply Last reply Reply Quote 0
        • I
          iperry
          last edited by

          Hi Phil,

          I am using the latest versions of Mango and the scripting modules (all the modules I have are the latest).

          It's odd that you cannot reproduce as it seems to occur every time I work with the scripting data source editor. I will try to create a new data source and see if the issue occurs. I haven't seen the behaviour in any other script editor. I have worked around this for now by moving the code to a global script (and calling that function from the scripting data source).

          Thanks for confirming when logging will occur.

          Ian

          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap
            last edited by

            Odd. Well, you could check the browser's developer tools. It should give some hint if it's hiding in the HTML or if some kind of JavaScript error occurred with displaying it. Perhaps export the data source and see if the saved script is intact?

            1 Reply Last reply Reply Quote 0
            • I
              iperry
              last edited by phildunlap

              Hi Phil,

              I created another scripting data source in case the original source had been corrupted. Same behaviour:
              0_1551902655468_43ca932b-b9ab-4fa6-8b34-f4d1bb71d469-image.png

              When I look at the elements in dev tools for the editor, there is nothing beyond the "i" and the elements look properly formed. Nothing is being hidden; the markup looks proper.

              Taking your suggestion, I exported the script and it appears that all the code is there:

              {
                 "dataSources":[
                    {
                       "xid":"DS_4eda2f4c-9c6b-4f43-ba77-ac4c44cdf9f9",
                       "name":"Scripting Test 2",
                       "enabled":false,
                       "type":"SCRIPTING",
                       "alarmLevels":{
                          "SCRIPT_ERROR":"URGENT",
                          "DATA_TYPE_ERROR":"URGENT",
                          "POLL_ABORTED":"URGENT",
                          "LOG_ERROR":"URGENT"
                       },
                       "purgeType":"YEARS",
                       "updateEvent":"CONTEXT_UPDATE",
                       "context":[
                       ],
                       "logLevel":"NONE",
                       "cronPattern":"0 * * * * ?",
                       "executionDelaySeconds":0,
                       "historicalSetting":false,
                       "logCount":5,
                       "logSize":1.0,
                       "script":"\r\nvar mqttPoints = [\r\n    {\r\n        deviceName: \"TEST 10\",\r\n        name: \"Buoy Id\",\r\n        templateXid: \"MQTT_Value\",\r\n        topic: \"buoyData\\\/10\",\r\n        path: \"\\\/id\"\r\n    }\r\n];\r\n\r\nvar dataSourceXid = \"DS_e71fa055-06f6-4e80-a1e8-b0b823378f3d\";\r\n\r\nfor (i=0; i<mqttPoints.length; i++) {\r\n    LOG.info('Creating data point: '+mqttPoints*.name);\r\n    createMQTTPoint(dataSourceXid, mqttPoints*);\r\n}\r\n\r\nfunction createMQTTPoint(dataSourceXid, values) {\r\n    var dataPoint = mqttDataPointTmpl;\r\n    \r\n    var xidPrefix = \"DP_TEST_\";\r\n    \r\n    dataPoint.xid = com.serotonin.m2m2.Common.generateXid(xidPrefix);\r\n    \r\n    dataPoint.dataSourceXid = dataSourceXid;\r\n    dataPoint.deviceName = values.deviceName;\r\n    dataPoint.name = values.name;\r\n    dataPoint.templateXid = values.templateXid;\r\n    \r\n    dataPoint.pointLocator.subscribeTopic = values.topic;\r\n    dataPoint.pointLocator.subscribeJsonValuePath = values.path;\r\n\r\n    JsonEmport.setImportDuringValidation(true);\r\n    print(JsonEmport.doImportGetStatus(JSON.stringify( {\"dataPoints\":[dataPoint]} )));\r\n}\r\n\r\n",
                       "scriptPermissions":{
                          "customPermissions":"",
                          "dataPointReadPermissions":"superadmin",
                          "dataPointSetPermissions":"superadmin",
                          "dataSourcePermissions":"superadmin"
                       },
                       "editPermission":"user",
                       "purgeOverride":false,
                       "purgePeriod":1
                    }
                 ]
              }
              

              So it's very odd that the editor is chopping the display of the code at the "<".

              Thanks
              Ian

              1 Reply Last reply Reply Quote 0
              • phildunlapP
                phildunlap
                last edited by phildunlap

                Okay. I was able to reproduce. I always put spaces after my < so somehow I've never crossed paths with this. Not sure if that's a new or old issue, but I'm looking into it. Thanks for bringing it to our attention and providing a failing case!

                1 Reply Last reply Reply Quote 0
                • I
                  iperry
                  last edited by iperry

                  Whew! Glad that you were able to reproduce it. heh

                  Edit: I see that having the space after the "<" prevents the chopping. Very odd... As I mentioned above, I have only seen this behaviour in the scripting data source editor.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post