Script to use JS to output to JSON File - Button Has An Error

I am trying to create edit a form in ReTool using a series of text inputs and then save that to an output file with the click of a button. The query runs successfuly but I get an error when I hit the button: “button3 has an error in a property.” I’m not getting my JSON file to download. Can anybody help me out?

 let oldJson = filepicker1.parsedValue
    let newRule =
    oldJson.rules[Select_Rule.value].yields[0].weight = newRule
    let newRule1;
    let newRule2;

if (oldJson.rules[Select_Rule.value].yields[1].weight != "undefined"){
  newRule1 =
  oldJson.rules[Select_Rule.value].yields[1].weight = newRule1

else if (oldJson.rules[Select_Rule.value].yields[1].weight != "undefined"){
  newRule2 =
  oldJson.rules[Select_Rule.value].yields[1].weight = newRule2

else {
  return utils.downloadFile(oldJson, 'output_ruleset', 'json')

I solved the issue related to getting my JSON to download. I still, however, am getting an error message next to my button indicating an error. Why?

@boz01 are you seeing red anywhere else in your app? Can you send a screenshot of your inspector (right panel) so we can see all the button settings?

Hey @justin good to hear from you. Here is a screenshot of my button settings. Do you know why I am getting the error msg?

@boz01 this is quite strange. Last thing - can you open your property browser (left side panel), navigate to your button, and screenshot the properties?

@justin I think it was just an old error message hanging around. I added a new button and linked the same query to it and it’s working with no error message

1 Like

Awesome! I take no credit for this :slight_smile: