triplebeta / TrelloExcelConnector

Import a Trello board into Excel, publish rows of data as cards and sync back changes from existing cards.
MIT License
16 stars 4 forks source link

Does not create cards correctly #8

Closed alvijagr closed 6 years ago

alvijagr commented 6 years ago

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?

alvijagr commented 6 years ago

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

Kaan191 commented 6 years ago

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.

alvijagr commented 6 years ago

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

Kaan191 commented 6 years ago

Well done alvijagr - works beautifully now!

triplebeta commented 6 years ago

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.