0
votes

I have a problem to update the values on the fields of a form. I cannot update the date in its respective text box and the spreadsheet that receives the values only shows the values after i refresh the page (both Ui and spreadsheet are embbeded in the Google Sites)

The var date, explicited as a global var

var date=new Date();

The TextBox

var DataTextBox=app.createTextBox().setId('Data').setName('Data').setValue(date).setReadOnly(true).setText(Utilities.formatDate(date, 'GMT -02:00', 'dd/MM/yyyy HH:mm:ss'))

The handler

var clickHandler2=app.createServerHandler('updateAll');
button.addClickHandler(clickHandler2);
clickHandler2.addCallbackElement(panel);

The function (have others fields updated, but they are working fine)

function updateAll(e) {
  //DataTextBox.setValue(date).setReadOnly(true).setText(Utilities.formatDate(date, 'GMT -02:00', 'dd/MM/yyyy HH:mm:ss'));
  var newDate=date;
  app.getElementById("Data").setValue(newDate);
  app.getElementById("TicketId").setValue("");
  app.getElementById("TicketType").setValue(TicketTypeArray[0]);
  app.getElementById("DemandedBy").setValue(DemandedByArray[0]);
  app.getElementById("Analyst").setValue(AnalystArray[0]);
  app.getElementById("Description").setValue("");
}

How do i update the date field and how can i make the spreadsheet shows the last data submited by the form?

1
aren't you missing a 'return app' at the end of your handler function ? what is the idea behind 'newDate=date' if 'date=new Date()' I don't understand why you do that...Serge insas
I thought that using the same logic as i did with the other fields, the date would update, making the script write again the value of date.Bruno Estrazulas
updateAll() also needs var app = UiApp.getActiveApplication(); first.Bryan P
Use a dateBoxJacobvdb

1 Answers

0
votes

You have to add 'return app' in order to show updated fields in gui.