Alex Zamai
Alex Zamai

Reputation: 169

Continuously import data from the From responses spreadsheet into AppMaker data model

In my organization, I have a pretty long(56 steps), well-defined google form. I'd like to use new responses of this form in my appmaker project. I could recreate the form in appmaker but this would be a huge manual labor. I want to avoid this by setting some kind of a data transfer between the responses spreadsheet and my appmaker project. And I do not have access to the cloudSQL option when creating the data model (presumably admin turned it off).

Question: Spreadsheet app-script has a method to listen to new updates, is there a way to send the new response data to the appmaker app?

Highly appreciate your ideas.

PS how do we call apps written in app maker? AMA?:)

Upvotes: 0

Views: 479

Answers (1)

Alex Zamai
Alex Zamai

Reputation: 169

Turns out the solution is quite simple:

Create a server side script that opens the spreadsheet and loads the data into the Model with the query

function getSSData(){
  var values = SpreadsheetApp.openById(FILE_ID).getSheets()[0].getDataRange().getValues();
  var ssData = [];
  for (var i = 0; i<values.length; i++){
    var newRecord = app.models.MODEL_NAME.newRecord();
   // add all fields to the new record
    newRecord.MODEL_FIELD = values[i][0];
    ssData.push(newRecord);
  }
// return the array of the model.newRecord objects that would be consumed by the Model query.
  return ssData;
}

And add call this function as a query script in Datasource of that model.

enter image description here

Upvotes: 2

Related Questions