I have a Google Form, and the results go to a Google Sheet. I wrote a Google Apps Script to create bulk PDFs from the spreadsheet.
There is a checkbox on the form, and the result that goes into the spreadsheet column is
Checked = "Check here if Information is same as above"
Unchecked = "" or NULL (I am not sure which)
This is the javascript to bulk create these PDFs. My problem is that it always comes through on the PDF as ?, even if there is nothing in that column. I have tried a multitude of way of putting it in different places, using brackets, etc. to no avail. I am a SQL gal, and this is literally the first javascript I have written, so any help is appreciated.
function CreateBulkPDFs() {
///////////begin function{
const docFile = DriveApp.getFileById("1YAj3MubVRnYUpptEmc92esU0e3vP4KknrgvCO4l9BkI");
const tempFolder = DriveApp.getFolderById("1gmCPUmXsl4iwaVWv-7l43-y82cz2ENfF");
const pdfFolder = DriveApp.getFolderById("1UNHFAlvT5ZMTrIevdsIyf27SgyfO6PQQ");
const currentSheet = SpreadsheetApp.openById("1oMmL0Wfl9FSFX7_xb4RH-qc2o4qJvhlkNMTKMkwHXB8").getSheetByName("Form Responses 1");
const data = currentSheet.getRange(2, 1, currentSheet.getLastRow() - 1, 49).getDisplayValues();
//getRange(row start, column start, # of rows, # of columns)
var chk;
let errors = [];
data.forEach(row => {
///////////begin forEach2(
///////////begin row2{
try {
///////////begin try{
if (row[1] !="Success")
if (row[28] = "Check here if Information is same as above") chk = "?";
if (row[28] != "Check here if Information is same as above") chk = "?";
CreatePDF(
row[2],
row[3],
row[4],
row[5],
row[6],
row[7],
row[8],
row[9],
row[10],
row[11],
row[12],
row[13],
row[14],
row[15],
row[16],
row[17],
row[18],
row[19],
row[20],
row[21],
row[22],
row[23],
row[24],
row[25],
row[26],
row[27],
//This is Check here if Information is same as above - row[28]
chk,
row[29],
row[30],
row[31],
row[32],
row[33],
row[34],
row[35],
row[36],
row[37],
row[38],
row[39],
row[40],
row[41],
row[42],
row[43],
row[44],
row[45],
row[46],
row[47],
row[48],
row[2] + " DOB: " + row[3], /*Name of Document*/
docFile,
tempFolder,
pdfFolder
);
errors.push(["Success"]);
}
///////////end try{
catch (err) {
errors.push(["Failed"]);
}
}
///////////end row {
);
///////////end forEach(
currentSheet.getRange(2, 2, currentSheet.getLastRow() - 1, 1).setValues(errors);
}
///////////end function{
question from:
https://stackoverflow.com/questions/65849963/i-am-basing-a-variable-on-a-spreadsheet-column-to-create-pdfs-in-google-apps-scr