I am attempting to copy the value of a cell to another cell using Apps Script. Source cell's value is produced by a query formula:
=sum(iferror(query(ExportDrop!$A$2:$AJ,"select AJ where A matches '" & join("|",C$3:C) & "' AND AH = '" & A3 & "'",0),0))
Source sheet displays the output of this query formula successfully and correctly.
Working within a script, the following code produces a zero (0), which is different than when viewing the sheet.
cellval = sourceSheet.getRange("B3").getValue();
SpreadsheetApp.getUi().alert(cellval); return;
I have attempted getDisplayValue(), getValue(), getValues() (with corresponding change to the range reference), using setActiveRangeSelection(), copyValuesToRange(), copyTo(,{contentsOnly: true}) etc.
Is this a bug in Google Sheet's query function? I wonder because the same thing occurs when I print to PDF the source sheet containing a query function. The resulting PDF shows zero-values. So it appears not to be an issue with my script, but more like an issue with the source sheet. Tests of a "simpler" query-formula sheet printed work fine.
What am I doing wrong?
EDIT:
Here is an example: https://docs.google.com/spreadsheets/d/1eHHV-TJhC_aVNNLspx3suKhrthtcjRfIcZR0dWdTvOI
Try printing Sheet2. The first PDF "preview" looks good, but upon opening the PDF after export, the sum values are all zeros.
matchesis not running on the server at all and only locally sort of like how theformatboolean feature is just false advertising on google's part. A simple web browser refresh sadly demonstrates this desync glitch. - CodeCamperflushit still displays zero even though it is 10 right in your face, thematchesis just not making it to the server at all, refreshing brings everything back to zero. - CodeCamper