triplebeta / TrelloExcelConnector

Import a Trello board into Excel, publish rows of data as cards and sync back changes from existing cards.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not create cards correctly

alvijagr opened this issue · comments

Hi. When I try to run "Publish" part it mixes up information.
Creates Card No.2 with information which was entered for Card No.3 and etc.
Any ideas on what can cause this?

Error given on immediate window: "400 - Bad Request
invalid value for idList"

I have experienced this too. Workaround at the moment is to shift all information in columns B to J down a row, and create a bogus entry in row 4. There has to be a simple fix but I'm only getting up to speed with VBA...
Otherwise, thanks so much for publishing this tool, it's a real time-saver for me.

I have found a fix, you need to replace Public Function "GetCards" with code below. You can find it under Class Modules -> Datasheet
Listname = TrelloSheet.Cells(i, pConfig.List) was in incorrect place

Public Function GetCards(board As TrelloBoard) As TrelloCard()
Dim AllCards() As TrelloCard, MyCard As TrelloCard, TrelloSheet As Worksheet, i As Integer
Dim CardColorsList As String, LabelsList As String, LabelIDsList As String
Dim CardCount As Integer, Membername As String, Listname As String
Dim AllLabelsForThisCard() As TrelloCardLabel

If board Is Nothing Then Err.Raise -100, "Datasheet", "Board cannot be null."
If Not pIsInitialized Then Err.Raise -101, "Datasheet", "You must first call Initialize() on this instance."

Set TrelloSheet = ActiveWorkbook.Sheets(pWorksheetname)
For i = pHeaderrow + 1 To TrelloSheet.UsedRange.Rows.Count
    If Trim(TrelloSheet.Cells(i, pConfig.Cardname)) <> "" Then
        Set MyCard = New TrelloCard
        
        Listname = TrelloSheet.Cells(i, pConfig.List)
        MyCard.cardId = TrelloSheet.Cells(i, pConfig.cardId)
        MyCard.Name = TrelloSheet.Cells(i, pConfig.Cardname)
        MyCard.Description = TrelloSheet.Cells(i, pConfig.CardDescription)
        MyCard.DueDate = TrelloSheet.Cells(i, pConfig.DueDate)
        MyCard.Position = TrelloSheet.Cells(i, pConfig.Position)
        Membername = TrelloSheet.Cells(i, pConfig.members)
        MyCard.AddMember board.LookupMemberIdByName(Membername)
        MyCard.ListId = board.LookupListIdByName(Listname)

        'Assign labels to the card
        Listname = TrelloSheet.Cells(i, pConfig.List)
        LabelsList = TrelloSheet.Cells(i, pConfig.Labels)
        CardColorsList = TrelloSheet.Cells(i, pConfig.CardColor)
        AllLabelsForThisCard = ComposeCardLabels(board.boardId, LabelIDsList, LabelsList, CardColorsList)
        Call MyCard.AddLabels(AllLabelsForThisCard)
        
        CardCount = CardCount + 1
        ReDim Preserve AllCards(CardCount)
        Set AllCards(CardCount) = MyCard
    End If
Next i
GetCards = AllCards

End Function

Well done alvijagr - works beautifully now!

Thanks @Kaan191 for reporting the issue and @alvijagr for suggesting the solution. Sorry I wasn't able to look into it quicker. I'll release a new version including your fix.