0
votes

I already read some answers to this question on stackoverflow but I was not able to get my case working.

I have the components in GUI Builder and the code runs to function respondToSubmit after pressing Submit button, but the fileName is undefined. fileName is the content of Name in Input Fields in component File Upload. Any Ideas what is wrong?

function respondToSubmit(e) {

  var app = UiApp.getActiveApplication();

  var fileBlob = e.parameter.fileName;

  throw(fileBlob); // fileBlob = undefined!!!

  return app;

}

enter image description here

RECENT CODE:

function doPost(e) {

throw("doPost"); // never thrown so code does not run here!

var app = UiApp.getActiveApplication();

var fileBlob = e.parameter.FileUpload1;

return app;

}

enter image description here

2

2 Answers

0
votes

I think you have to have your labels, text boxes, and submit buttons all in a Flow Panel, which then has to be enveloped by a Form Panel. I had this exact same problem, even the 'Unexpected Error'. I solved it by putting all of those elements into a Flow Panel.

0
votes

There are two types of buttons - one is the regular button and the other is a Submit button (which can be placed only on a form panel)

  1. Make sure you are using the Submit button and not a regular button

  2. When you use a Submit button, there is no need to provide a handler function. Submit buttons, by default get handled by a special function called doPost(e). So, write a doPost function and you will be able to filename parameter.

The FileUpload widget documentation has a nice example of how this is done.