grahamearley/FirestoreGoogleAppsScript

getting the id of a new document created

Closed this issue · 1 comments

I am able to create document from a Google Sheet

Something like this

const firestore = FirestoreApp.getFirestore(email, key, projectId);
 ...
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheets = ss.getSheets();
 var sheet = ss.getActiveSheet();

 var data = sheet.getDataRange().getValues();
 var parentid = '';
 var childid = '';
 for (i = 1; i < data.length; i++) {
    var title = data[i][0];
    const docjson = {
      'title': title
    };
    parentid = firestore.createDocument('collection1', docjson); 
    // this gives an error
  }

Explain the Problem in Detail

I would like the generated id because I would like to use it to dynamically create a subcollection

Library Version:

33

Thanks

Oh. It does generate a json. My bad.