JSON.stringify error while looping input file


#1

Hi,

I want to enter the values from an input file to a website and submit. However, the particular site that I am using causes the error Error in runEval code: JSON.stringify is not a function when i try to increment the value of !csvReadLineNumber using storeEval. If I change the website to https://a9t9.com/ the entire macro works correctly!
Below is a stripped down testcase made to help replicate this error.

{
  "CreationDate": "2018-11-8",
  "Commands": [
    {
      "Command": "store",
      "Target": "180",
      "Value": "!timeout_macro"
    },
    {
      "Command": "store",
      "Target": "medium",
      "Value": "!replayspeed"
    },
    {
      "Command": "open",
      "Target": "http://164.100.128.10/mfmsReports/getSaleOfProductGroupWise",
      "Value": ""
    },
    {
      "Command": "csvRead",
      "Target": "FertilizerSales_v1.csv",
      "Value": ""
    },
    {
      "Command": "while",
      "Target": "\"${!csvReadStatus}\" == \"OK\"",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "status = ${!csvReadStatus}, line = ${!csvReadLineNumber}, value=${!COL1}  ${!COL2}  ${!COL3}",
      "Value": "blue"
    },
    {
      "Command": "storeEval",
      "Target": "${!csvReadLineNumber}+1",
      "Value": "!csvReadLineNumber"
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "!errorIgnore"
    },
    {
      "Command": "echo",
      "Target": "Reading CSV line No.  ${!csvReadLineNumber}",
      "Value": "!errorIgnore"
    },
    {
      "Command": "csvRead",
      "Target": "FertilizerSales_v1.csv",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "false",
      "Value": "!errorIgnore"
    },
    {
      "Command": "endWhile",
      "Target": "",
      "Value": ""
    }
  ]
}

Contents of the file FertilizerSales_v1.csv

IFFCO,“01/09/2018”,“30/09/2018”
IPL,“01/09/2019”,“30/09/2019”

Also, I have signed up as a beta tester for Kantu about a month ago. Is this the correct forum in which to report errors and seek help? Is there anyway I can troubleshoot rather than just send the error message to the forum.


#2

Ah… it seems that your website blocks script execution. Javascript in storeEval is run in the context of the website. We have seen similar reports, for example, with macros on github.com

Workaround: A workaround will be to switch to a different website (e. g. have a9t9.com open in a different tab) while you run storeEval, and then switch back.

Solution: We will soon release an update where a new version of storeEval can run in a sandbox, so websites can no longer disturb or block it.


[Feature Request] [Issue #279] Error in runEval code: Refused to evaluate a string as JavaScript because 'unsafe-eval'
#3

This works !! Thank you very much :slight_smile: