Spreadsheet WriteRow Error 4401 when Sending a Formula

Hi everyone,

I'm working on an App Inventor project where I need to send a formula to a Google Spreadsheet using the WriteRow function of the Spreadsheet component.

What I'm Trying to Do:

  • I have a column for start date/time (Column E).
  • I have a column for end date/time (Column F).
  • In another column (Column G), I want to send a formula that calculates the time difference:
    Example formula: =F2-E2 (if the row index is 2).
  • The formula should dynamically update based on the row number.

How I'm Generating the Formula:

I tried using the join block to create the formula dynamically:

blocks:

set Formula_Celula to join "=" "F" global index "-E" global index

If global indexCliente = 2, this should create:
=F2-E2

Then, I add this formula to my list and send it using WriteRow:

The Problem:

Whenever I try to send this formula, I get the following error:
"4401 error in spreadsheet: WriteRow 400 Bad Request"

What I Tried:

  1. I checked that global index is a valid row number.
  2. I used Notifier1.ShowAlert to confirm that Formula_Celula generates correctly (it does).
  3. I tried adding " " around the formula to ensure it's sent as text.

    imagem_2025-01-30_092635525

Questions:

  • Is there a specific format required to send formulas with WriteRow?
  • Does the Spreadsheet component block formulas?
  • Is there a workaround to insert a formula dynamically into a new row?

Any help would be greatly appreciated! :blush:

I just tested with WriteCell and this works OK

image

and for WriteRow, also works OK here

image

You may need to check all the values you are sending, particularly the date...the obvious date you are sending is string which could be causing problems with the formula in any case. Convert both your date/times to milliseconds for simple calculation, then convert this as required (Days/Hrs/Mins/Secs)

Also search this board for my Marathon sample