Open an excel sheet

TIMAI2 Can you help me understand where the error is?

There is something wrong with your script deployment.

HELLO TIMAI2, THIS is the script if I run it below I get an error

function doGet(e) {

  var ss = SpreadsheetApp.openById(e.parameter.sheetID);
  var sh = ss.getSheetByName(e.parameter.SH);
  var fn = e.parameter.FN;
  var rg = sh.getDataRange().getValues();
  
  // enter row number and column number to return A1 Notation Cell reference
  if ( fn == 'getCellRef' ) {
    var ref = sh.getRange(e.parameter.ROW,e.parameter.COL).getA1Notation();
    return ContentService.createTextOutput(ref);
  } 
  
  // enter start and end row numbers and column numbers to return A1 Notation Range reference
  else if ( fn == 'getRangeRef' ) {
    var ref = sh.getRange(e.parameter.ROW,e.parameter.COL,e.parameter.ROW1,e.parameter.COL1).getA1Notation();
    return ContentService.createTextOutput(ref);
  }
  
  // enter A1 notation reference to return cell value
  else if ( fn == 'readCell' ) {
    var ref = sh.getRange(e.parameter.REF).getValue();
    return ContentService.createTextOutput(ref);
  }
  
  // enter row number to return all values in row as a list
  else if ( fn == 'readRow' ) {
    var ref = sh.getRange(parseInt(e.parameter.ROW),1,1,rg[0].length).getValues();
    return ContentService.createTextOutput(JSON.stringify(ref));
  }
  
  // enter column number (A=1/B=2/etc.) to return all values in column as a list
  else if ( fn == 'readCol' ) {
    var ref = sh.getRange(2,parseInt(e.parameter.COL),rg.length-1,1).getValues();
    return ContentService.createTextOutput(JSON.stringify(ref));
  }
  
  // enter A1 notation reference to return range values as a list
  else if ( fn == 'readRange' ) {
    var ref = sh.getRange(e.parameter.REF).getValues();
    return ContentService.createTextOutput(JSON.stringify(ref));
  }
  
  // returns all values on sheet, including headers
  else if ( fn == 'readSheet' ) {
    return ContentService.createTextOutput(JSON.stringify(rg));     
  }
 
  // outputs results for SQL query of all data  
  else if ( fn == 'querySheet' ) {
    var sql = e.parameter.SQL;
    var hdr = e.parameter.HDR;
    if ( hdr == 0 ) {
    var rgq = sh.getName() + "!" + sh.getDataRange().getA1Notation().replace('A1','A2');
    var qry = '=query(' + rgq + ';\"' + sql + '\";0)';
    } else if ( hdr == 1 ) {
    var rgq = sh.getName() + "!" + sh.getDataRange().getA1Notation();
    var qry = '=query(' + rgq + ';\"' + sql + '\";1)';
    }
    var ts = ss.insertSheet();
    var setQuery = ts.getRange(1,1).setFormula(qry);
    var getResult = ts.getDataRange().getValues();
    ss.deleteSheet(ts); 
    return ContentService.createTextOutput(JSON.stringify(getResult));
  }
  
  // enter row number to delete that row
  else if ( fn == 'deleteRow' ) {
    sh.deleteRow(parseInt(e.parameter.ROW));
    return ContentService.createTextOutput('Row ' + e.parameter.ROW + ' has been deleted');
  }
  
  // enter row number to delete that row
  else if ( fn == 'deleteCol' ) {
    sh.deleteColumn(parseInt(e.parameter.COL));
    return ContentService.createTextOutput('Column ' + e.parameter.COL + ' has been deleted');
  }
  
  // enter A1 notation reference to write cell value
  else if ( fn == 'writeCell' ) {
    sh.getRange(e.parameter.REF).setValue(e.parameter.DATA);
    return ContentService.createTextOutput('Value: ' + e.parameter.DATA + ' written to cell ' + e.parameter.REF);
  }
  
  // enter row number to write row values
  else if ( fn == 'writeRow' ) {
    var data = JSON.parse('[' + e.parameter.DATA + ']');
    sh.getRange(e.parameter.ROW,1,1,data[0].length).setValues(data);
    return ContentService.createTextOutput('Values: ' + e.parameter.DATA + ' written to row ' + e.parameter.ROW);

  }
  
  // enter row number to write row values
  else if ( fn == 'writeCol' ) {
    var data = JSON.parse(e.parameter.DATA);
    sh.getRange(1,e.parameter.COL,data.length,1).setValues(data);
    return ContentService.createTextOutput('Values: ' + e.parameter.DATA + ' written to column ' + e.parameter.COL);
  }
  
  // enter A1 notation reference to write cell values
  else if ( fn == 'writeRange' ) {
    var data = JSON.parse(e.parameter.DATA);
    var ref = sh.getRange(e.parameter.REF).setValues(data);
    return ContentService.createTextOutput('Values: ' + e.parameter.DATA + ' written to cells ' + e.parameter.REF);
  }
  
  // append row to end write row values
  else if ( fn == 'appendRow' ) {
    var data = JSON.parse('[' + e.parameter.DATA + ']');
    var lr = sh.getLastRow();
    sh.insertRowAfter(lr);
    rowNum = lr + 1;
    sh.getRange(rowNum,1,1,data[0].length).setValues(data);
    return ContentService.createTextOutput('Values: ' + e.parameter.DATA + ' appended');
  }
  
  // append column to end and write column values
  else if ( fn == 'appendCol' ) {
    var data = JSON.parse(e.parameter.DATA);
    var lc = sh.getLastColumn();
    sh.insertColumnAfter(lc);
    colNum = lc + 1;
    sh.getRange(1,colNum,data.length,1).setValues(data);
    return ContentService.createTextOutput('Values: ' + e.parameter.DATA + ' appended');
  }
  
  // enter A1 notation reference and formula to set formula to cell
  else if ( fn == 'insertFormula' ) {
    var ref = sh.getRange(e.parameter.REF).setValue(e.parameter.DATA);
    return ContentService.createTextOutput('Formula: ' + e.parameter.DATA + ' inserted to  ' + e.parameter.REF);
  }
}

strong text Log esecuzione

15:14:46

Notifica

Esecuzione avviata

15:14:46

Errore

TypeError: Cannot read properties of undefined (reading 'parameter')

doGet

@ Code.gs:3

If the above is line 3 in your script, then it seems your sheetID is incorrect or missing ?

This is the sheetID for the spreadsheet from above link that you wanted to edit:
17O4PkI-U0vdjEytijh24Q-lg9fsMWj87
with a sheetname of Turni e Reperibilità H24 - 2023

This is the sheetID in your app (for the GSAI2 extension:
16UpesE3a8ym6ANgGzXXQZGuCZMg5AY5TrNXf8uvO_yg
with a sheetname of Foglio1

This is the sheetID it's wrong , this my doc


I have just tested the extension with your spreadsheet using my script and it works OK.

Something wrong with your script deployment

thanks, did you change it for me?

which script should I put in place of the current one

pls replace the script code with this scripts from the link below and deploy once again with option Anyone

As said by tim, it is working fine, if i use above scripts and run.

see

image

help the script is the same, please help me, mine doesn't work.
I do not understand
New_Crs_Group.aia (1.3 MB)

Your blocks/app appears to be working OK. That is not the problem.

Show how you have deployed the script....

no I understand
I open the sheet from google extensions app script
please help me where I'm wrong at screen app, screen file, app.aia



New_Crs_Group.aia (1.3 MB)

The script url shown on the deployment page is different to the one you show in your app.

Did you set?

si Eveyone

I have to enter

https://script.google.com/macros/s/AKfycbxqiU3-pgsz9RtFr-_77snViyKbma8wOZYynUCIDVHwEPlBgAtL5LPKEdZfdq6TY3Fx/exec

and delete in GSAI21 SCRIPTURL

https://script.google.com/macros/s/AKfycbzI6IEISTsrAo2BVdh8Fkt3fo6nfoaTVWBiZvxzZKx8XIf2dvU/exec

CORRECT?

if you run the latest Script url in browser, it should return
Exception: Invalid argument: id (line 5, file "Code") but yours both of the above url returns page not found error. It means you have not deployed correctly it seems. You are missing something. Always run the script url in this format

<Use_Your_script_url>?ID=<use_your_sheet_ID>&SH=<use_your_sheet_name>&FN=readRow&ROW=2

if the above code returns value of 2nd row then your deploy is good else, you are dpoing mistake at anywhere.. (Note; please remove < and > symbol. it is used to denote the places where you want to addthe reqiurd things)

Yes, always replace the latest script url with the previous one

Seems you have not been doing this (in order to keep the script url the same)

I don't understand, everything is ok for me.
you have everything about my app but if you try it and it works
can you tell me what to change please
I'm going crazy