I have a spreedsheet where I want to have a unique id for the row, I use the Utilities
method getUuid
.
I don´t want it to get the Utilities.getUuid()
method when insertion of a row happens, so I want to get the value from the cell where the insertion has been made and check if it's empty then generate a new uuid if not, do nothing.
function uuid() {
const ss = SpreadsheetApp.getActive();
const sheet = ss.getActiveSheet();
const activeRange = sheet.getActiveRange();
const val = activeRange.getValue();
Logger.log(val)
if(!val) {
return Utilities.getUuid();
}
}
What steps will reproduce the problem?
- Spreadsheet with values at least 2 rows and 2 cols
- col #2 has the
=uuid(true)
in order to calculate the uuid
What is the expected output?
- After the insertion of a row in between the two rows, the row below should not change the uuid
- The logger of the
val
should retrieve the value but it shows#ERROR!