google-sheetsgoogle-apps-scriptadd-oncustom-function

Call client side Javascript from Google Apps Script server side code


My Google Sheets Add-On opens a sidebar (which includes a complete React based application in an iframe) that shows a 3d graphic.

The Add-On also includes a custom function that can be called from any cell.

Is there a way for the cell function to communicate with the Javascript in the sidebar (eg. a field referenced in the function call is changed, the custom function is recalculated (by Sheets) and the Add-On wants to show some side effect of the calculation (update the graphic) in the sidebar (without reopening it).

NB: I could use the client side Javascript to poll the Add-On and return my updates this way, or I could post my updates to my own server (via URL Fetch) and use websockets or sse to post the event to my client side code. But I would prefer a simpler method.


Solution

  • There seems to be no way of communicating directly between the cell function and the browser based JavaScript in the sidebar.