.setValue () does not work consistently for Google Sheets Script

I was struggling with a chunk of script I wrote on Google Sheet. The purpose of the script is to monitor the input value (from the keyboard) for a given cell and check that the input conforms to the data input standard.

For example, all input values ​​must conform to the standard XX-XX-X

. As an example, let's say A5-03-1

, while B555-01-1

not. (The first component is 4 digits instead of 2.) When the input value does not conform to the standard, I use the command .setValue()

to delete the entry ...

Sheet.getRange(active cell).setValue("");

      

A .setValue()

message box also appears in the tag :

Browser.msgBox("Expecting format ''XX-XX-X''. \\n Please re-enter data.");

      

The logical instructions for this code work fine. What doesn't work is this .setValue()

. Sometimes it erases the entry at will, otherwise it leaves an invalid entry. However, the message box is always displayed accordingly. Both activities are in the same logical test.

Also, I have provided authorization to a script containing setValue()

. But I get daily error emails for this worksheet with errors on the line "This action requires authorization".

Finally, I have other ways to enter data into this sheet. All users have granted access to the script.

+3


source to share


1 answer


I'm not sure why the function is setValue()

not working, but try using clear()

after use instead getRange()

.



0


source







All Articles