How can I add a unique integer short id (function number) for each card in trello?

I wrote a web script that generates a function number for trello card ID

and stores it in the database.

I also created a webhook that is executed when the trello board changes

When I create a map, the webhook sends a request to the callbackURL, but the request does not contain any event data. It only contains information about the model (about the board). How to get the ID of a new card?

{
    "model"=>{
        "id"=>"5204523d8d3432ff1a000a60",
        "name"=>"#BOARD",
        "desc"=>"",
        "descData"=>nil,
        "closed"=>false,
        "idOrganization"=>"53aaf6e5309dc12a75111fbf",
        "pinned"=>false,
        "url"=>"https://trello.com/b/ABdAaJeO/board",
        "shortUrl"=>"https://trello.com/b/ABdAaJeO",
        "prefs"=>{
            "permissionLevel"=>"org",
            "voting"=>"disabled",
            "comments"=>"members",
            "invitations"=>"members",
            "selfJoin"=>false,
            "cardCovers"=>true,
            "calendarFeedEnabled"=>true,
            "background"=>"river",
            "backgroundColor"=>nil,
            "backgroundImage"=>"https://d2a2fgsv6pobq6.cloudfront.net/images/backgrounds/river/full.jpg",
            "backgroundImageScaled"=>[
                {
                    "width"=>2400,
                    "height"=>1600,
                    "url"=>"https://d2a2fgsv6pobq6.cloudfront.net/images/backgrounds/river/large.jpg"
                },
                {
                    "width"=>1024,
                    "height"=>683,
                    "url"=>"https://d2a2fgsv6pobq6.cloudfront.net/images/backgrounds/river/medium.jpg"
                },
                {
                    "width"=>320,
                    "height"=>213,
                    "url"=>"https://d2a2fgsv6pobq6.cloudfront.net/images/backgrounds/river/small.jpg"
                }
            ],
            "backgroundTile"=>false,
            "backgroundBrightness"=>"dark",
            "canBePublic"=>true,
            "canBeOrg"=>true,
            "canBePrivate"=>true,
            "canInvite"=>true
        },
        "labelNames"=>{
            "green"=>"",
            "yellow"=>"",
            "orange"=>"frontend",
            "red"=>"bugs",
            "purple"=>"",
            "blue"=>"backend",
            "sky"=>"",
            "lime"=>"",
            "pink"=>"",
            "black"=>""
        }
    },
    "feature"=>{

    }
}

      

PS We use Scrum and now use Trello for this. For each function, we create one card per trello. We create prefixed git branches containing the feature number (f231_feature, etc.). When I push changes, I want to automatically add a comment to the trello map.

We are using integers for all functions, but the trello card id is too long to use. Trello card has integer code (etc. 231 in URL https://trello.com/c/2zrZE33/231-trello ), but these codes are unique within the same board and this is not for us because we are moving completed cards to a different board.

+3


source to share


1 answer


I get a response from the Trello team:

If your webhook is configured to view the board as hers model

, then you should receive the following information on your web check POST

:

 "card": {
                "shortLink": "wKiG3zv8",
                "idShort": 42,
                "name": "I'm a new card",
                "id": "55478b893a73ba2e400381c6"
            }

      



In this case, the option shortLink

is the best way to store the feature number for Trello, by selecting https://www.trello.com/c/ [the value of shortLink] you can pull the card. Alternatively, you can use the full "id" of the card, also provided in this POST. Either option works as a unique identifier for the card in Trello.

This information is contained in the data array, not in the "model" array. For information on the action that has been taken, this would be the best place to watch.

I checked my script and found an error. The Trello webhook request does POST

indeed send not only the object model

, but action

information, including information about the new card.

+1


source







All Articles