I have this piece of code that is working perfectly when I use it in a standalone Google Script running as a web-app :
function getSubjectsRollNosFromGradeSheet() {
var spreadsheetId = '171hWWH8bV6kM1JJ2dvL80q3BoWC6eEc0U7l7wCTaXHE';
var rangeSubject = 'GradesT1!G1:AA1';
var values = Sheets.Spreadsheets.Values.get(spreadsheetId, rangeSubject).values;
However when I write this same code in a Script that is embedded inside another Google sheet (not the one being accessed for data) attached to a Google Form I get an error :
function updateForm(){
// call your form and connect to the drop-down item
var form = FormApp.openById("1VV_LeFJODZcIzfcYOh8vHEkhl033Lx4ZsXaY4Pm1ZUE");
var subList1 = form.getItemById("497738674").asListItem();
//pull data from another sheet
var spreadSheetID = "1EJSx62rZuLSKIgel7LH8hE7-68lupz4buutmVQBqi2I";
var rangeSubs = 'Sheet1!A1:A';
var subValues = Sheets.Spreadsheets.Values.get(spreadSheetID, rangeSubs).values;
I get this error
ReferenceError: "Sheets" is not defined. (line 16, file "Code")
Why is the Sheets object available in the first case but not in the second case and how should I change my code to overcome this error.