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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Position of lists via API api.trello.com/1/lists

The position I post to the API api.trello.com/1/lists is returned differently to me than what I pass in.

Example:

const options = { 
method: "POST",
uri: `https://api.trello.com/1/lists`,
qs: {
name: "some list name",
idBoard: boardId,
pos: 1.0,
key: key,
token: token
}

};

Trello returns: pos: 1.125

{
"id": "9dkd03m4405da5d3",
"name": "some list name",
"closed": false,
"idBoard": "99akd03020494kd",
"pos": 1.125,
"limits": {}
}

Sometimes Trello will return something that's not even close to what I passed in.

For example I pass in a position of 9.0 and I get 2056 in return!

2 answers

0 votes
Iain Dooley Community Leader Jul 04, 2019

@Christopher Andersson Yeah the position is represented differently internally than the numbers you pass in.

If you want to find out the position of a list, you'd need to grab all the visible lists in the board, sort by the position attribute and then find out where it sits.

I have also been wanting to create new lists in specific positions within a board.

I definitely was confused by the difference between the position shown in the UI, which is simply a counting number, starting at 1 and going up to the number of lists on the board, and the .pos value in the API, which is a floating point number often going up to six digits plus three decimal digits. I also notices that Trello seems fond of adding a .125 (1/8) to whole number values.

Using the UI number in the API was not working for me because it turned out that the list at UI position #1 had a .pos value of 2056. I was telling the API that I wanted the new List all the way down at position #10 and it would still create it at the far left.

Then I found an article that explained the difference. Floating point numbers are used so that Trello can insert new items many, many times while still leaving the existing .pos values intact, rather than recalculating .pos values each and every time you add anything.

At first I thought I had to find the position values of both the list to the left and the list to the right of the new list and calculate a position value someplace in between. But it turned out, at least in my case, to be much easier than that because Trello does all that invisibly.

I simply get the .pos position of the list to the left of my desired location and then use that value as the position of the new list. When adding a new list, Trello automatically places it to the right of the existing list at that given position. That's all I needed.

Because I know Trello can recalculate the .pos values any time I add something, in fact I am counting on it, I do not save those values from one session to the next nor do I assume that any of the .pos values stay the same after I add something. I expect the returned .pos value to be different from the submitted .pos value.

This applies to the order of cards in a list too.

I hope this helps.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Trello

📹 What is Trello?

Hello Community!  My name is Brittany Joiner and I am a Trello enthusiast and Atlassian Community Leader. I'll be sharing with you a series of videos with my top tips on how to best use Trello...

330 views 10 22
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you