diff --git a/server/publications/swimlanes.js b/server/publications/swimlanes.js index cec9230c9..533f5159c 100644 --- a/server/publications/swimlanes.js +++ b/server/publications/swimlanes.js @@ -4,19 +4,20 @@ Meteor.methods({ check(toBoardId, String); const swimlane = Swimlanes.findOne(swimlaneId); - const board = Boards.findOne(toBoardId); + const fromBoard = Boards.findOne(swimlane.boardId); + const toBoard = Boards.findOne(toBoardId); - if (swimlane && board) { + if (swimlane && toBoard) { swimlane.lists().forEach(list => { - const boardList = Lists.findOne({ + const toList = Lists.findOne({ boardId: toBoardId, title: list.title, archived: false, }); let toListId; - if (boardList) { - toListId = boardList._id; + if (toList) { + toListId = toList._id; } else { toListId = Lists.insert({ title: list.title, @@ -42,7 +43,7 @@ Meteor.methods({ }); // make sure there is a default swimlane - this.board().getDefaultSwimline(); + fromBoard.getDefaultSwimline(); return true; }