MrQNet
MrQNet

Reputation: 5

Google Apps Script - Use utilities class

I am just learning the apps script for Google Apps and I see lots of references to the Utilities and Math Classes. How do I go about adding these classes to my script. When I try to reference methods an error appears.

Code I have tried:

function myTest() { 
    var name = (new Date()).toLocaleDateString(); 
    var ss = SpreadsheetApp.getActiveSpreadsheet(); 
    var sht_0 = ss.getActiveSheet(); 
    var sht_1 = ss.insertSheet(name); 
    SpreadsheetApp.setActiveSheet(sht_0); 
    utilities.sleep(10000); 
    var rng = sht_0.setActiveRange('A1:A5'); 
    sht_0.setActiveRange(rng); 
}

The Error I get:

ReferenceError: "utilities" is not defined. (line 7, file "Code")

Thanks Ian

Upvotes: 0

Views: 2130

Answers (1)

RanaIssa
RanaIssa

Reputation: 71

I didn't try your code, but I think you just need to put the word "utilities" as "Utilities" (with capital U). I'm using this method from the Utilities class and it works without errors:

return Utilities.getUuid().toString();

I hope this helps!

Upvotes: 0

Related Questions