I'm building a Google Spreadsheet-based app in Google Script. One of the things it does is output a selection of items attached to a parent item in rows. I'd like for the user to be able to open an editing interface for these items by clicking an image that is also generated for each row.
In Google Sheets, you can right-click on an inserted image to open a contextual menu and attach a script to it. Google Script lets you use the assignScript method to assign a script to an image in the sheet, but for some reason when you call that function it pops this error: "Script function function editContract(){ Logger.log("contract edit") } could not be found"
Here's the code. Nothing complicated!
var fileId = '17-6V_HBlSGwHW-_NeLzUo5kizxxrYOjG';
var img = DriveApp.getFileById(fileId).getBlob();
// Insert the image in cell.
searchSheet.insertImage(img, 10, writeRow);
// now we need to attach a script to that image
images = searchSheet.getImages();
images[images.length - 1].assignScript(editContract);