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

How can we associate checklist to card?

Ringo July 3, 2018

    private Card setCheckListOnCard(Card c,CheckList cl){
        List<String> arrayIdOfCheckList=new ArrayList<>();
        String cardId=c.getId(); //returns empty
        cl.setId(String.valueOf(UUID.randomUUID());
        String checkListId=cl.getId();

        arrayIdOfCheckList.add(checkListId);
        c.setIdChecklists(arrayIdOfCheckList);
        Card updatedCard=c.update();

        return updatedCard;
    }


How can we associate checklist to card?

Assume that the card already exists on trello server side in this snippet thus the card has an ID.
On the other hand,my check list exists only on my client side at this point so the checklist does not have an ID,
I tried to set unique id to the checklist here.

With c.setIdChecklists(arrayIdOfCheckList),  Card c is successfully associated with
an arrayIdOfCheckList however, after card is updated, returned (Card)updatedCard losts
arrayIdOfCheckList.

Do you have any idea of what's wrong with my snippet?

2 answers

0 votes
Ringo July 4, 2018

Hi Oscar

 

The library used here is https://github.com/taskadapter/trello-java-wrapper.

And you are true.

 

There's a method that send prepared checklist to trello instance

and returns singed checklist by server.

CheckList signedCheckList=trello.createCheckList(c.getId(),preparedChecklist);

 

signedCheckList has a key and successfully set to a card.

 

Thanks.

0 votes
Oscar Triscon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2018

Hi Ringo,

I'm not familiar with the library you're using to interact with the Trello API, but you don't get to set your own IDs for checklists. Just like for any other Trello element, they are set by the server.

What you do is to POST to /1/checklists with a payload containing a checklist name and the id of the card. This will return an id for the checklist. Optionally, you can copy an existing checklist by specifying the id of the source checklist.

https://trello.readme.io/v1.0/reference#checklists

Then, you can POST the items one by one to /1/checklists/ID/checkItems, where ID is the previously returned checklist id.

https://trello.readme.io/v1.0/reference#checklistsidcheckitems

 

In your library, it's likely that there is another function to create a checklist and to add items to it.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events