testing123
testing123

Reputation: 829

Google apps script variable declaration greyed out

My script apparently stopped working after google updated. I haven't changed the script.

  var newSheet = blankSheet.makeCopy(newEstimate, estimatesFolder);
  var newSheetId = newSheet.getId();
  var newSheetUrl = newSheet.getUrl();
  var newDocUrl = 'https://docs.google.com/document/d/' + copyId + '/edit';
  var lastRow = ss.getLastRow();

  var sheetCell = ss.getRange('R'+lastRow).setValue('=HYPERLINK("'+newSheetUrl+'","'+newSheetId+'")');
  var docCell = ss.getRange('S'+lastRow).setValue('=HYPERLINK("'+newDocUrl+'","'+copyId+'")');

The var sheetCell and the var docCell are greyed out but I don't know why?

Upvotes: 0

Views: 2341

Answers (1)

Marios
Marios

Reputation: 27360

Explanation:

Since you haven't indicated any error message, I will shortly explain the greyed out variable declerations.

The decleration for sheetCell and docCell is unnecessary for two reasons:

  1. you don't use these variables anywhere in the code after they are declared.
  2. while setValue returns a range object, it is not necessary to store it somewhere since its job is to set a value in a cell. In other words, most of the times you don't need the object that it returns.

Answer:

Because you declare variables that you don't use the new editor gives you an alert message to indicate that the declaration of these variables is redundant. This is just a warning message and it is up to you if you want to remove the decleration or not.

enter image description here

Upvotes: 3

Related Questions