Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Getting shared power-up data from another user

Dominic P. January 18, 2021

Referencing: Getting and Setting Data

When I store data in the member scope with visibility shared, how am I supposed to retrieve this data from the t object when I'm logged in as another user?

 

Example

Logged in as user1: I store something via

t.set('member', 'shared', key, value)

Then, logged in as user2 (admin on the board): I want to retrieve the value stored for user1. Since I've set visibility to shared, I expect this to be possible. The docs also state:

A visibility of shared means that any Trello member who can see the object it is stored against (determined by Scope) can see the data.

However, I can only get my own data using

t.get('member', 'shared', key, defaultValue)

 

Is there something I'm missing here? I've also tried to pass a user id instead of 'member', but this gives me an error: "Card not found or not on current board (Command: data)" since it treats the first value as a card id.

 

Any help appreciated,
Thank you ;)

3 answers

1 accepted

1 vote
Answer accepted
Travis Hamera January 19, 2021

In general i've found it best to use the rest api for interacting with trello data, even within the powerups. That said, I haven't seen a good way route for interacting with a different user's plugin data either.  The board approach isn't a bad idea as long as your user count isn't too high.  There's always the option of creating a small data set wherever you are hosting your powerup to store lightweight user data.  

Dominic P. January 21, 2021

Yeah, true, we can always store something on the server hosting the plugin, haven't thought of it ;)

I'll go with the board approach for now, storing keys on the board in the form

"<attributeName>-<userId>": <value>

At least, I can now update all the keys for every member using t.set(...) and the board scope.

Would be great to see the Trello REST API support PUT, POST and DELETE methods for managing pluginData. Why would t.set(...) (where you can actually update key-value pairs) be more powerful than the REST API itself?

1 vote
Travis Hamera January 21, 2021

Don't forget that you can also store at the organization level to if it's global data you want to store in other boards.  I use that to capture info about my users and overall setting that I want to extend across all boards using my powerup within a particular team.

Dominic P. January 21, 2021

Thanks, that's a great option, will definitely try this out.

0 votes
Dominic P. January 18, 2021

As a workaround, I've stored the data in the board scope with individual keys that have the user id appended, like:

const key = `myKey-${userId}`
t.set('board', 'shared', key, value)

and retrieve it the other way round.

But this is not optimal, since - logically - I'd say that something I want to store for a member should beloing to this member's scope.

 

I could also fetch the Trello REST API using the endpoint

/members/:id/pluginData

but the problem is, as the docs state

Currently, PUT, POST, and DELETE methods are not supported for managing pluginData.

So, I couldn't update or delete a key from another user (key-scope member with visibility shared) using this approach.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events