Is there a way in Butler variables to reference the list position on a board?
Asked by Michael Stephens:

Our team would like to have one of our boards used to set priority for all projects for the group. Essentially, the high level goal would be to infer priority for tasks (cards) based on which list they fall into where the left most list is the highest priority.

This information is readily available on the main board in question but gets lost when we sync across to other boards via Unito.

We've been looking at the list of Butler variables here:

* <https://help.trello.com/article/1157-variables>

As well as at this post which indicates we can define the list position we want and hoping to be able to do the inverse if this is possible (read list position vs declare which list to add a card to):

* <https://help.trello.com/article/1163-reference-list-by-position-instead-of-name>

The ideal workflow:

* Click and drag lists around to set priority on a board
* On list position change (via a rule) or manually via a board button, have a custom field updated on each card with the priority level
* This priority level would be the list position number

It would also be great to know the total number of lists on a board. Is this possible?


Answers:
author: milynnus
body: [@Michael Stephens](/t5/user/viewprofilepage/user-id/558844)

Using http request with a custom endpoint to update the priority of the cards based on list relative pos of the list is probably what you need.

comments: author: Michael Stephens
body: Thank you [@milynnus](/t5/user/viewprofilepage/user-id/3947182)

I didn't know that was a feature to query trello from trello and just looked into REST API. Very neat.

That said, I followed the following steps and don't get what I would need:

* Generated an API key and token for myself
* Added a GET request for the event to query:  
  * [https://api.trello.com/1/lists/{cardlistid}?key=\[my-key\]\&token=\[my-token](https://api.trello.com/1/lists/{cardlistid}?key=[my-key]&token=[my-token)\]
* Posted the results as a comment

I see the following fields accessible to me:

* id
* name
* closed
* pos
* idBoard

Presumably 'pos' would be position but the values returned are seemingly random. For instance, the following values from three lists on my board:

* 98303.25
* 131071
* 117759.1015625

Is there a way to run a second query to get the position details? Am I missing anything in terms of fields? For reference, I'm using the following for the API details:

* <https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-group-lists>

Additionally, I'm wondering about the practicality of this route. I would hope for every member on the team to be able to utilize this rule. Will this simply work by having my key and token posted / used in the rule? Is there a way to query my own Trello instance within Trello without needing the key and token?


author: milynnus
body: [@Michael Stephens](/t5/user/viewprofilepage/user-id/558844)

I am glad you like the feature.   

I do not use it with just native api calls but to an endpoint. That way you can do more. Generally I would have basic authentication at the endpoint. That way the api key and token are kept as .secret variables with python libraries for Trello.   
For your use case you probably need to get all the list pos and sort it to get the priority once you have dragged the list in position and then update the CF with the relative pos values.   

if you have 2 way sync for CF you have to be careful how that might affect your workflow.


author: Michael Stephens
body: [@milynnus](/t5/user/viewprofilepage/user-id/3947182)

I'll be honest, I'm a bit lost as to what you mean by at the endpoint. I'm not super familiar with REST/API calls and not sure how / what can be done to not result in public keys being seen. I agree and don't like would be plain text in the URLs for our workspace.

The aim of feature is to know position in list when anyone shuffles so if there is a prompt to login that exceeds the benefit of the feature for us. We want this to be part of the native web client feature vs local scripts/things we are running to interact with Trello remotely.

I don't know if *pos* is actually position. The documentation here for 'TrelloList' says it is just a number with no defining meaning provided. :

* <https://developer.atlassian.com/cloud/trello/rest/api-group-actions/#api-actions-id-list-get>

Additionally, I ran a query for all lists and the values go up and down in value from left to right so multiple queries and sorting them wouldn't help us.

I can also run a query that returns all lists on a board (containing the same details but the wrapper for all lists). That does give us implied order as the summary top-down matches the list ordering left-to-right. That said, I'm not sure how I can use a rule in Trello to do logical checks (loop over list and find entry that matches the current ID and use that index as value to write for priority).

It may very well I'm looking for more than Trello can do natively and that we would need to make an external application / script to handle the logic and run it when we want to run it but the extra overhead is non-ideal.


author: milynnus
body: [@Michael Stephens](/t5/user/viewprofilepage/user-id/558844)

The exit provided by Trello for third party services is the http action. The other options would be webhooks or custom power up. All will require use of some code and it's api.  


author: Michael Stephens
body: From [@milynnus](/t5/user/viewprofilepage/user-id/3947182) ' s suggestion, this feature request is not possible within the bounds of our needs. For those finding this in the future, you can look to go the route of third party / eternal integration but we will be skipping this feature want as it impractical for our time and effort.

It is nice that the information can be scraped but I do wish one of the Trello exposed variables was list position.

Thank you [@milynnus](/t5/user/viewprofilepage/user-id/3947182) for your help.


author: milynnus
body: [@Michael Stephens](/t5/user/viewprofilepage/user-id/558844)

Workaround : manually create a list for lookup with cardname = listname and card description = priority. When can is moved into list ; lookup card with name = {triggercardlistname}, set cf equal {foundcarddescription}. Try it.


author: Michael Stephens
body: Thank you [@milynnus](/t5/user/viewprofilepage/user-id/3947182) for the suggestion. I'm sure that can work based on other experiments I've done but the main thing we're trying to achieve is not needing to edit a description/set a priority level manually and simply infer from positioning on one board and report to a second board. We can achieve a similar result with our current work around of adding a priority number to the list name itself and using that in the custom field we use for list name at the moment.