I have been working on a sheet which has been working AOK with
`
var UI = SpreadsheetApp.getUi();
`on the fifth line. Suddenly I was getting the can not call from context message. Landed here and decided I would try to close and open the sheet and voila, error is gone. Strange goings on......