Cell value not been updated while editing

Do you want to: Report a bug / how-to question
Document Server version: 9.3.1.8
Additional information:
Hello,

The following code works well generally

	var sheet = Api.GetActiveSheet();
    var cell = sheet.GetActiveCell();
	
    cell.SetValue("test")
    console.debug(cell.GetValue());

However, if the user edits the cell (for example by pressing F2), the changes are not processed, and cell.GetValue() returns the value of the cell from before entering edit mode.

Is there a way to force the cell to exit edit mode so I can retrieve the current value and/or modify it?

best,

Hey @humbol, :wave:

Thanks for the clear code example — I see exactly what you’re running into.

The value you get with cell.GetValue() is pulled from the database, not from the current in-memory edit state. While the user is typing in a cell (edit mode active, F2 pressed), the changes are not yet committed to the DB — they only get saved after the user finishes editing and moves focus to another cell (Enter, Tab, click elsewhere). That’s why GetValue() returns the old value until then.

You’ll see “All changes saved” at the bottom only after the edit is committed.

In your scenario, the editor doesn’t even know the new value exists yet because it hasn’t been flushed to the backend.

Could you tell me a bit more about your exact use case?

  • What are you trying to achieve with GetValue() right after/during edit?
  • Do you need the value while the user is still typing, or only after they finish?
  • Are you building a plugin, macro, or using the JS API from an external integration?

Once I understand the goal, we can probably find solution (or confirm if it’s a limitation that needs a feature request).

Thanks — looking forward to your reply! :hugs:

Hi Nikolas,

Thank you for your support. I am currently working on two scenarios where I am encountering this issue.

In the first scenario, which is similar to the ONLYOFFICE playground (Playground | ONLYOFFICE), I have several actions located outside of the ONLYOFFICE frame that trigger specific macros. Frequently, after modifying a cell, users click these external buttons without exiting the cell. As a result, the macros do not do the expected changes.

The second issue is related, I guess. Some of my external functions trigger a save operation. I request the “forcesave” command service from the server side, but again, then current field are not saved if the user is didn’t exit that cell.

I hope it helps. Thanks again for your help.

Best,

Humberto