How to use addMultiBlocks

Just reading through monday.execute, I want to use addMultiBlocks to add some blocks to a specific WorkDoc. Looking at the documentation, it does not tell you how to specify the WorkDoc. How do I do that?

In contrast, the API for adding a block to a workdoc allows we to specify the doc_id if I use create_doc_block.

Hello there @danielball,

There is no place to specify the doc’s ID. This is because it is automatically taken from the context when the SDK method is being used in a doc-related app feature :smile:

1 Like

Hello there @danielball,

That SDK method automatically takes the doc ID from the context when being used in a doc-related app feature :smile:

1 Like

Ok, can I put in a feature request to do this in a workspace context please.

Hello there @danielball,

If you want to use this method outside of a doc-related feature (which is what you want to do if I understand correctly), you can create a feature for it here :smile:

I added Multi-block add outside of WorkDoc context

Essentially I’m looking for the most efficient way to programmatically create a workdoc and then populate it with blocks (from either the SDK or API). The options right now are a bit limited for this purpose.

Thank you @danielball for the feature request!

Hey @Matias.Monday,

I have one final thought on this. As an experiment I used the API to create add a single block to an existing document. Then I used the block ID returned by the API call to fill in the afterBlockId argument for addMultiBlocks.

This failed as expected because I was calling this from a workspace app with the message Error: "addMultiBlocks" execute command isn't available or supported for this app feature type. This is understandable as there is no document context for a workspace app.

What I’m thinking though is that because the block ID is a UUID it makes it universal and therefore you can infer the document context from it. Would it therefore be possible to change the SDK implementation of monday.execute so that when the afterBlockId is supplied you infer the document context even for workspace apps.

This way, you don’t have to change the SDK interface or even the documentation. It may be a small internal code change but will make the SDK much more useful for workspace apps.