user531065
user531065

Reputation: 763

Calling a google sheets custom function from another custom function

I am trying the following in a Google Sheet which produces an error because although function_2() correctly returns an object when I test it in the editor (or when I set it to return JSON.stringify and call it in the spreadsheet directly which displays correct JSON), that object is somehow converted to an empty string when it should be passed to function_1() as a parameter:

=function_1(B2,B3,function_2(A1,A2))

Any ideas?

Upvotes: 1

Views: 1398

Answers (1)

Wicket
Wicket

Reputation: 38130

Custom functions should return a single value or an array of values in order to work in a Google Sheets formulas.

The value or values should be valid Google Sheets values, in other words, number, text, boolean or date.

JavaScript objects types that are converted to valid Google Sheets are

  • Number to number. Percentage, currency and other number formats depend on Google Sheets formatting.
  • String to text.
  • Date to date.
    • Note: Conversion to time, date-time or duration depends on cell formatting but duration could be complicated
  • Boolean to boolean.

Reference

Upvotes: 1

Related Questions