Custom function execution context sheet

Posted by: n.serrette on 22 September 2022, 8:01 pm EST

    • Post Options:
    • Link

    Posted 22 September 2022, 8:01 pm EST


    I am trying to create a custom function which need to be aware of its execution context.

    By using isContextSensitive and returning true I can get a context object during the evaluation which contains de cell coordinates.

    However, in my case I also need the sheet or at least a mean to find it (name or index).

    For the moment the only way I could think of was adding a field to my function with the sheet name and adding the function to each worksheet.

    Ideally I would like to be able to instantiate the function once on the workbook level and getting the sheet from the context.

    Is their a proper way to do it?


  • Posted 25 September 2022, 11:22 pm EST


    We are sorry but for a custom function, the contexct is not exposed you use the custom async function for getting the context of the evaluation. The first argument on evaluate method(on AsyncFunction Class) is nothing but the object of context.

    Please refer to the following code snippet:

      asum.prototype.evaluateAsync = function ([b]context[/b], arg) {
          // do evaluate on server to get result ...



  • Posted 26 September 2022, 12:27 am EST

    Is their any hope to see an execution context publicly exposed in the future, containing at least the reference (worksheet, col, row) of the executed function?

  • Posted 27 September 2022, 9:53 pm EST


    We have made an enhancement request on your behalf. We will update you regarding this as soon as we get any information from the team. The internal ID for this issue will be SJS-14911.



  • Posted 28 September 2022, 1:52 am EST

    Thank you

  • Posted 29 September 2022, 3:17 pm EST


    The team infromed us that When implementing the custom function, the customer could overwrite the isContextSensitive, and return true.

    Then, the context will be the first args of the evaluate function.




  • Posted 29 September 2022, 6:23 pm EST


    Thank you for your answer,

    Is it possible to have an interface describing the context object?

    I noticed that the object are different between the AsyncFunction and the Function.

    The AsyncFunction seems to encapsulate the Function context.


  • Posted 5 October 2022, 4:10 pm EST


    We are sorry but the evaluateContext is not a public type.

    basically, you could get

    row - the function evaluation row.

    column - the function evaluate column.

    sheet - arguments[0].source.getSheet(), the function evaluate sheet.



  • Posted 5 October 2022, 6:02 pm EST - Updated 5 October 2022, 6:03 pm EST


    Thank for your reply.


Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels