UmbDocumentWorkspaceContext mulitple save methods

in the api docs there appears to be two options for saving your document, requestSave() and requestSubmit().

https://apidocs.umbraco.com/v17/ui-api/classes/packages_documents_documents.UmbDocumentWorkspaceContext.html#requestsave

What is the difference and should I be using a particular one to save the current document progress in my custom extension?

Hi @Gavin5656

The naming isn’t obvious, but they sit at different levels.

requestSubmit() is the full flow. It validates first, then saves, and it’s exactly what the Save button triggers. You get validation, the server round trip, the success/error notifications and the workspace state updating to match. The document workspace has separate _handleSave() and _handleSubmit() hooks under the hood, which is why you’re seeing two public methods.

requestSave() is the lower level one that drives the save without the full submit functionality around it.

For saving the current progress in your extension, go with requestSubmit(). It’s the same operation a user gets when they hit Save, so validation, notifications and state are all handled for you. I’d only reach for requestSave() if you specifically needed to skip part of that, and you’d be giving up the validation step in the process.

Both are async, so remember to await before you do anything that relies on the save having completed.

Justin

1 Like