Answered

Plugin widgets.get() by id doesn't seem to work

  • 23 October 2020
  • 3 replies
  • 681 views

Hi,

 

I am trying to get widgets by id using the await miro.board.widgets.get({ id }) but it doesn’t appear to work? I have tried single ids, array of ids, both with strings and integers and nothing comes back? Is that expected behaviour?

 

This is within the onReady callback;

 

Thanks,

 

Craig

icon

Best answer by Daniela Gavidia 27 October 2020, 09:09

View original

3 replies

It would appear by type is the only filter that works, which is a bit unexpected. Unless I am using the wrong method perhaps?

Userlevel 4
Badge

Hello Craig,

In order to get a specific widget by id, you have to filter like this:
await miro.board.widgets.get({id: <WIDGET_ID>})

This will return an array of matching widgets. Since widget ids are unique, it will be an array of length one. For example, you can get a specific widget by id like this:

 

You can check the type declaration file to see how to call any specific method in the SDK. For the widget.get() method, see this line:
https://github.com/miroapp/app-examples/blob/master/miro.d.ts#L321
 

I hope this clarifies things.

Kind regards.

 

Daniela

Hmm I am doing this. I’ll retest it later on but what I have is an app that creates a number of sticker widgets and then adds them to a tag.

On a resync of the data I find all the tags and then for each of the tag.widgetIds I am then trying to get each widget via the await miro.board.widgets.get({id: <WIDGET_ID>}) call and it was returning an empty array for each? 🤷

 

Reply