Mass import of cards from text lines #262

Open
opened 2026-02-04 18:10:48 +03:00 by OVERLORD · 16 comments
Owner

Originally created by @snan on GitHub (Dec 27, 2022).

Hi y'all ♥

Is it possible to move a whole bunch of cards from one board to another board, maybe by first moving the entire list over? I found that you can move cards individually from the card's context menu, but what if you have dozens of cards?

And, is it possible to import cards from text lines or other formats (other than Trello)? I tried pasting but it created a card with newlines in the title 🤷🏻‍♀️

Originally created by @snan on GitHub (Dec 27, 2022). Hi y'all ♥ Is it possible to move a whole bunch of cards from one board to another board, maybe by first moving the entire list over? I found that you can move cards individually from the card's context menu, but what if you have dozens of cards? And, is it possible to import cards from text lines or other formats (other than Trello)? I tried pasting but it created a card with newlines in the title 🤷🏻‍♀️
OVERLORD added the enhancement label 2026-02-04 18:10:48 +03:00
Author
Owner

@meltyshev commented on GitHub (Dec 29, 2022):

I agree with you, these missing features would be useful.

@meltyshev commented on GitHub (Dec 29, 2022): I agree with you, these missing features would be useful.
Author
Owner

@snan commented on GitHub (Dec 29, 2022):

I was thinking of something—maybe it is possible to do them by making SQL queries directly?

@snan commented on GitHub (Dec 29, 2022): I was thinking of something—maybe it is possible to do them by making SQL queries directly?
Author
Owner

@meltyshev commented on GitHub (Dec 29, 2022):

I've written a little script to copy all the cards from the list to the list. Warning: I haven't tested it well!

To run it, you have to enter the sails console: cd server and PORT=1338 npx dotenv sails console.

(async () => {
  const USER_EMAIL_OR_USERNAME = 'USER_EMAIL_OR_USERNAME_HERE';
  const FROM_BOARD_ID = 'FROM_BOARD_ID_HERE';
  const TO_BOARD_ID = 'TO_BOARD_ID_HERE';
  const FROM_LIST_NAME = 'FROM_LIST_NAME_HERE';
  const TO_LIST_NAME = 'TO_LIST_NAME_HERE';

  const user = await sails.helpers.users.getOneByEmailOrUsername(USER_EMAIL_OR_USERNAME);
  if (!user) {
    console.error('User not found');
    return;
  }

  const fromBoard = await Board.findOne(FROM_BOARD_ID);
  if (!fromBoard) {
    console.error('From board not found');
    return;
  }

  const toBoard = await Board.findOne(TO_BOARD_ID);
  if (!fromBoard) {
    console.error('To board not found');
    return;
  }

  const fromList = await List.findOne({
    boardId: fromBoard.id,
    name: FROM_LIST_NAME,
  });
  if (!fromList) {
    console.error('From list not found');
    return;
  }

  const toList = await List.findOne({
    boardId: toBoard.id,
    name: TO_LIST_NAME,
  });
  if (!fromList) {
    console.error('To list not found');
    return;
  }

  const cards = await sails.helpers.lists.getCards(fromList.id);
  for (card of cards.reverse()) {
    await sails.helpers.cards.updateOne.with({
      user,
      record: card,
      values: {
        position: 0,
        board: toBoard,
        list: toList,
      },
      board: fromBoard,
      list: fromList,
    });
  }
})();
@meltyshev commented on GitHub (Dec 29, 2022): I've written a little script to copy all the cards from the list to the list. **Warning: I haven't tested it well!** To run it, you have to enter the sails console: `cd server` and `PORT=1338 npx dotenv sails console`. ``` (async () => { const USER_EMAIL_OR_USERNAME = 'USER_EMAIL_OR_USERNAME_HERE'; const FROM_BOARD_ID = 'FROM_BOARD_ID_HERE'; const TO_BOARD_ID = 'TO_BOARD_ID_HERE'; const FROM_LIST_NAME = 'FROM_LIST_NAME_HERE'; const TO_LIST_NAME = 'TO_LIST_NAME_HERE'; const user = await sails.helpers.users.getOneByEmailOrUsername(USER_EMAIL_OR_USERNAME); if (!user) { console.error('User not found'); return; } const fromBoard = await Board.findOne(FROM_BOARD_ID); if (!fromBoard) { console.error('From board not found'); return; } const toBoard = await Board.findOne(TO_BOARD_ID); if (!fromBoard) { console.error('To board not found'); return; } const fromList = await List.findOne({ boardId: fromBoard.id, name: FROM_LIST_NAME, }); if (!fromList) { console.error('From list not found'); return; } const toList = await List.findOne({ boardId: toBoard.id, name: TO_LIST_NAME, }); if (!fromList) { console.error('To list not found'); return; } const cards = await sails.helpers.lists.getCards(fromList.id); for (card of cards.reverse()) { await sails.helpers.cards.updateOne.with({ user, record: card, values: { position: 0, board: toBoard, list: toList, }, board: fromBoard, list: fromList, }); } })(); ```
Author
Owner

@zezretro commented on GitHub (Jul 3, 2023):

Sorry for extra questions. How do you access the sails console? I am running in docker and I can log into the containers console. thank you

@zezretro commented on GitHub (Jul 3, 2023): Sorry for extra questions. How do you access the sails console? I am running in docker and I can log into the containers console. thank you
Author
Owner

@meltyshev commented on GitHub (Jul 4, 2023):

Sorry for extra questions. How do you access the sails console? I am running in docker and I can log into the containers console. thank you

Hi! Please try this: docker exec -t planka-planka-1 /bin/bash -c "export PORT=1338 && npx dotenv sails console"
You might need to change the name of the planka-planka-1 container to your name.

@meltyshev commented on GitHub (Jul 4, 2023): > Sorry for extra questions. How do you access the sails console? I am running in docker and I can log into the containers console. thank you Hi! Please try this: `docker exec -t planka-planka-1 /bin/bash -c "export PORT=1338 && npx dotenv sails console"` You might need to change the name of the `planka-planka-1` container to your name.
Author
Owner

@zezretro commented on GitHub (Jul 4, 2023):

Got into the sails console, thank you!

@zezretro commented on GitHub (Jul 4, 2023): Got into the sails console, thank you!
Author
Owner

@zezretro commented on GitHub (Jul 16, 2023):

Hiyas

I took the above sails code and asked chatGPT to update it so that it now reads all the lists in the source board and moves all of them to the target board. If the list doesnt exist it creates it.

When using ChatGPT I found it easier to ask it to update the code in stages and tested it at each step. First I asked it to create a list if it doesnt exist. Then I asked it to accept an input string array of source lists. Then I asked it again to read all lists from the input board.

The same disclaimer as above: this worked for me but has not been extensively tested. List position isn't handled well, you might need to manually rearrange

(async () => {
  const USER_EMAIL_OR_USERNAME = 'USERNAME_OR_EMAIL';
  const FROM_BOARD_ID = 'SOURCE_BOARD_ID';
  const TO_BOARD_ID = 'TARGET_BOARD_ID';

  const user = await sails.helpers.users.getOneByEmailOrUsername(USER_EMAIL_OR_USERNAME);
  if (!user) {
    console.error('User not found');
    return;
  }

  const fromBoard = await Board.findOne(FROM_BOARD_ID);
  if (!fromBoard) {
    console.error('From board not found');
    return;
  }

  const toBoard = await Board.findOne(TO_BOARD_ID);
  if (!toBoard) {
    console.error('To board not found');
    return;
  }

  const fromLists = await List.find({ boardId: fromBoard.id });
  if (fromLists.length === 0) {
    console.error('No lists found in the from board');
    return;
  }

  for (const fromList of fromLists) {
    let toList = await List.findOne({
      boardId: toBoard.id,
      name: fromList.name,
    });
    if (!toList) {
      // Create the target list if it doesn't exist
      toList = await List.create({
        boardId: toBoard.id,
        name: fromList.name,
        position: 0,
      }).fetch();
    }

    const cards = await sails.helpers.lists.getCards(fromList.id);
    for (const card of cards.reverse()) {
      await sails.helpers.cards.updateOne.with({
        user,
        record: card,
        values: {
          position: 0,
          board: toBoard,
          list: toList,
        },
        board: fromBoard,
        list: fromList,
      });
    }
  }
})();

@zezretro commented on GitHub (Jul 16, 2023): Hiyas I took the above sails code and asked chatGPT to update it so that it now reads all the lists in the source board and moves all of them to the target board. If the list doesnt exist it creates it. When using ChatGPT I found it easier to ask it to update the code in stages and tested it at each step. First I asked it to create a list if it doesnt exist. Then I asked it to accept an input string array of source lists. Then I asked it again to read all lists from the input board. The same disclaimer as above: this worked for me but has not been extensively tested. List position isn't handled well, you might need to manually rearrange ``` (async () => { const USER_EMAIL_OR_USERNAME = 'USERNAME_OR_EMAIL'; const FROM_BOARD_ID = 'SOURCE_BOARD_ID'; const TO_BOARD_ID = 'TARGET_BOARD_ID'; const user = await sails.helpers.users.getOneByEmailOrUsername(USER_EMAIL_OR_USERNAME); if (!user) { console.error('User not found'); return; } const fromBoard = await Board.findOne(FROM_BOARD_ID); if (!fromBoard) { console.error('From board not found'); return; } const toBoard = await Board.findOne(TO_BOARD_ID); if (!toBoard) { console.error('To board not found'); return; } const fromLists = await List.find({ boardId: fromBoard.id }); if (fromLists.length === 0) { console.error('No lists found in the from board'); return; } for (const fromList of fromLists) { let toList = await List.findOne({ boardId: toBoard.id, name: fromList.name, }); if (!toList) { // Create the target list if it doesn't exist toList = await List.create({ boardId: toBoard.id, name: fromList.name, position: 0, }).fetch(); } const cards = await sails.helpers.lists.getCards(fromList.id); for (const card of cards.reverse()) { await sails.helpers.cards.updateOne.with({ user, record: card, values: { position: 0, board: toBoard, list: toList, }, board: fromBoard, list: fromList, }); } } })(); ```
Author
Owner

@maxsmooth commented on GitHub (Nov 14, 2024):

I've written a little script to copy all the cards from the list to the list. Warning: I haven't tested it well!

To run it, you have to enter the sails console: cd server and PORT=1338 npx dotenv sails console.

I tried this script but it gives me the following error:

In call to updateOne(), 1 of the provided values (user) does not correspond with any recognized input.
Please try again without the extra value, or check your usage and adjust accordingly.
 [?] See https://sailsjs.com/support for help.
    at REPL174:46:45
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
- - - - - - - - - - - - - - - - - - - - - - - -
Uncaught OperationalError [UsageError]: Could not run updateOne() because of 3 problems:
------------------------------------------------------
• Invalid "values":
  · Value ({
  position: 0,
  board: {
    id: '1378340230758663180',
    createdAt: 2024-11-13T11:55:59.665Z,
    updatedAt: null,
    position: 131070,
    name: 'pippo',
    projectId: '1378336384875496451'
  },
  list: {
    id: '1378343634822235161',
    createdAt: 2024-11-13T12:02:45.462Z,
    updatedAt: null,
    position: 65535,
    name: 'dewqfewf',
    boardId: '1378340230758663180'
  }
}) failed custom validation.
• "project" is required, but it was not defined.
• "actorUser" is required, but it was not defined.
------------------------------------------------------

Please adjust your usage and try again.
 [?] See https://sailsjs.com/support for help.
    at REPL174:46:45
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error [UsageError]: Could not run updateOne() because of 3 problems:
  ------------------------------------------------------
  • Invalid "values":
    · Value ({
    position: 0,
    board: {
      id: '1378340230758663180',
      createdAt: 2024-11-13T11:55:59.665Z,
      updatedAt: null,
      position: 131070,
      name: 'pippo',
      projectId: '1378336384875496451'
    },
    list: {
      id: '1378343634822235161',
      createdAt: 2024-11-13T12:02:45.462Z,
      updatedAt: null,
      position: 65535,
      name: 'dewqfewf',
      boardId: '1378340230758663180'
    }
  }) failed custom validation.
  • "project" is required, but it was not defined.
  • "actorUser" is required, but it was not defined.
  ------------------------------------------------------
  
  Please adjust your usage and try again.
   [?] See https://sailsjs.com/support for help.
      at REPL174:46:45
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    code: 'E_INVALID_ARGINS',
    problems: [
      'Invalid "values":\n' +
        '  · Value ({\n' +
        '  position: 0,\n' +
        '  board: {\n' +
        "    id: '1378340230758663180',\n" +
        '    createdAt: 2024-11-13T11:55:59.665Z,\n' +
        '    updatedAt: null,\n' +
        '    position: 131070,\n' +
        "    name: 'pippo',\n" +
        "    projectId: '1378336384875496451'\n" +
        '  },\n' +
        '  list: {\n' +
        "    id: '1378343634822235161',\n" +
        '    createdAt: 2024-11-13T12:02:45.462Z,\n' +
        '    updatedAt: null,\n' +
        '    position: 65535,\n' +
        "    name: 'dewqfewf',\n" +
        "    boardId: '1378340230758663180'\n" +
        '  }\n' +
        '}) failed custom validation.',
      '"project" is required, but it was not defined.',
      '"actorUser" is required, but it was not defined.'
    ]
  },
  isOperational: true,
  code: 'E_INVALID_ARGINS',
  problems: [
    'Invalid "values":\n' +
      '  · Value ({\n' +
      '  position: 0,\n' +
      '  board: {\n' +
      "    id: '1378340230758663180',\n" +
      '    createdAt: 2024-11-13T11:55:59.665Z,\n' +
      '    updatedAt: null,\n' +
      '    position: 131070,\n' +
      "    name: 'pippo',\n" +
      "    projectId: '1378336384875496451'\n" +
      '  },\n' +
      '  list: {\n' +
      "    id: '1378343634822235161',\n" +
      '    createdAt: 2024-11-13T12:02:45.462Z,\n' +
      '    updatedAt: null,\n' +
      '    position: 65535,\n' +
      "    name: 'dewqfewf',\n" +
      "    boardId: '1378340230758663180'\n" +
      '  }\n' +
      '}) failed custom validation.',
    '"project" is required, but it was not defined.',
    '"actorUser" is required, but it was not defined.'
  ]
}
@maxsmooth commented on GitHub (Nov 14, 2024): > I've written a little script to copy all the cards from the list to the list. **Warning: I haven't tested it well!** > > To run it, you have to enter the sails console: `cd server` and `PORT=1338 npx dotenv sails console`. I tried this script but it gives me the following error: ```WARNING: Automatically trimmed extraneous values! In call to updateOne(), 1 of the provided values (user) does not correspond with any recognized input. Please try again without the extra value, or check your usage and adjust accordingly. [?] See https://sailsjs.com/support for help. at REPL174:46:45 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) - - - - - - - - - - - - - - - - - - - - - - - - Uncaught OperationalError [UsageError]: Could not run updateOne() because of 3 problems: ------------------------------------------------------ • Invalid "values": · Value ({ position: 0, board: { id: '1378340230758663180', createdAt: 2024-11-13T11:55:59.665Z, updatedAt: null, position: 131070, name: 'pippo', projectId: '1378336384875496451' }, list: { id: '1378343634822235161', createdAt: 2024-11-13T12:02:45.462Z, updatedAt: null, position: 65535, name: 'dewqfewf', boardId: '1378340230758663180' } }) failed custom validation. • "project" is required, but it was not defined. • "actorUser" is required, but it was not defined. ------------------------------------------------------ Please adjust your usage and try again. [?] See https://sailsjs.com/support for help. at REPL174:46:45 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { cause: Error [UsageError]: Could not run updateOne() because of 3 problems: ------------------------------------------------------ • Invalid "values": · Value ({ position: 0, board: { id: '1378340230758663180', createdAt: 2024-11-13T11:55:59.665Z, updatedAt: null, position: 131070, name: 'pippo', projectId: '1378336384875496451' }, list: { id: '1378343634822235161', createdAt: 2024-11-13T12:02:45.462Z, updatedAt: null, position: 65535, name: 'dewqfewf', boardId: '1378340230758663180' } }) failed custom validation. • "project" is required, but it was not defined. • "actorUser" is required, but it was not defined. ------------------------------------------------------ Please adjust your usage and try again. [?] See https://sailsjs.com/support for help. at REPL174:46:45 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 'E_INVALID_ARGINS', problems: [ 'Invalid "values":\n' + ' · Value ({\n' + ' position: 0,\n' + ' board: {\n' + " id: '1378340230758663180',\n" + ' createdAt: 2024-11-13T11:55:59.665Z,\n' + ' updatedAt: null,\n' + ' position: 131070,\n' + " name: 'pippo',\n" + " projectId: '1378336384875496451'\n" + ' },\n' + ' list: {\n' + " id: '1378343634822235161',\n" + ' createdAt: 2024-11-13T12:02:45.462Z,\n' + ' updatedAt: null,\n' + ' position: 65535,\n' + " name: 'dewqfewf',\n" + " boardId: '1378340230758663180'\n" + ' }\n' + '}) failed custom validation.', '"project" is required, but it was not defined.', '"actorUser" is required, but it was not defined.' ] }, isOperational: true, code: 'E_INVALID_ARGINS', problems: [ 'Invalid "values":\n' + ' · Value ({\n' + ' position: 0,\n' + ' board: {\n' + " id: '1378340230758663180',\n" + ' createdAt: 2024-11-13T11:55:59.665Z,\n' + ' updatedAt: null,\n' + ' position: 131070,\n' + " name: 'pippo',\n" + " projectId: '1378336384875496451'\n" + ' },\n' + ' list: {\n' + " id: '1378343634822235161',\n" + ' createdAt: 2024-11-13T12:02:45.462Z,\n' + ' updatedAt: null,\n' + ' position: 65535,\n' + " name: 'dewqfewf',\n" + " boardId: '1378340230758663180'\n" + ' }\n' + '}) failed custom validation.', '"project" is required, but it was not defined.', '"actorUser" is required, but it was not defined.' ] } ```
Author
Owner

@zezretro commented on GitHub (Nov 14, 2024):

Were you able to get the original script to run? the one at the top of this thread which was posted by the app author. maybe that gives insight as to if your error is with this updated script or something else

@zezretro commented on GitHub (Nov 14, 2024): Were you able to get the original script to run? the one at the top of this thread which was posted by the app author. maybe that gives insight as to if your error is with this updated script or something else
Author
Owner

@maxsmooth commented on GitHub (Nov 14, 2024):

Were you able to get the original script to run? the one at the top of this thread which was posted by the app author. maybe that gives insight as to if your error is with this updated script or something else

the one at the top of this thread which was posted by the app author.

@maxsmooth commented on GitHub (Nov 14, 2024): > Were you able to get the original script to run? the one at the top of this thread which was posted by the app author. maybe that gives insight as to if your error is with this updated script or something else the one at the top of this thread which was posted by the app author.
Author
Owner

@zezretro commented on GitHub (Nov 14, 2024):

I tried the script now and I also got the same error

I suspect the underlying data structure has changed since this script was written

@meltyshev could you provide any hints how to update the script?

@zezretro commented on GitHub (Nov 14, 2024): I tried the script now and I also got the same error I suspect the underlying data structure has changed since this script was written @meltyshev could you provide any hints how to update the script?
Author
Owner

@meltyshev commented on GitHub (Nov 14, 2024):

Hi! Yes, the structure has already been changed. Please try the following version:

(async () => {
  const USER_EMAIL_OR_USERNAME = 'USERNAME_OR_EMAIL';
  const FROM_BOARD_ID = 'SOURCE_BOARD_ID';
  const TO_BOARD_ID = 'TARGET_BOARD_ID';

  const user = await sails.helpers.users.getOneByEmailOrUsername(USER_EMAIL_OR_USERNAME);
  if (!user) {
    console.error('User not found');
    return;
  }

  const {
    board: fromBoard,
    project: fromProject,
  } = await sails.helpers.boards.getProjectPath(FROM_BOARD_ID);

  const {
    board: toBoard,
    project, toProject,
  } = await sails.helpers.boards.getProjectPath(TO_BOARD_ID);

  const fromLists = await List.find({ boardId: fromBoard.id });
  if (fromLists.length === 0) {
    console.error('No lists found in the from board');
    return;
  }

  for (const fromList of fromLists) {
    let toList = await List.findOne({
      boardId: toBoard.id,
      name: fromList.name,
    });
    if (!toList) {
      // Create the target list if it doesn't exist
      toList = await List.create({
        boardId: toBoard.id,
        name: fromList.name,
        position: 0,
      }).fetch();
    }

    const cards = await sails.helpers.lists.getCards(fromList.id);
    for (const card of cards.reverse()) {
      await sails.helpers.cards.updateOne.with({
        record: card,
        values: {
          position: 0,
          project: toProject,
          board: toBoard,
          list: toList,
        },
        project: fromProject,
        board: fromBoard,
        list: fromList,
        actorUser: user,
      });
    }
  }
})();
@meltyshev commented on GitHub (Nov 14, 2024): Hi! Yes, the structure has already been changed. Please try the following version: ``` (async () => { const USER_EMAIL_OR_USERNAME = 'USERNAME_OR_EMAIL'; const FROM_BOARD_ID = 'SOURCE_BOARD_ID'; const TO_BOARD_ID = 'TARGET_BOARD_ID'; const user = await sails.helpers.users.getOneByEmailOrUsername(USER_EMAIL_OR_USERNAME); if (!user) { console.error('User not found'); return; } const { board: fromBoard, project: fromProject, } = await sails.helpers.boards.getProjectPath(FROM_BOARD_ID); const { board: toBoard, project, toProject, } = await sails.helpers.boards.getProjectPath(TO_BOARD_ID); const fromLists = await List.find({ boardId: fromBoard.id }); if (fromLists.length === 0) { console.error('No lists found in the from board'); return; } for (const fromList of fromLists) { let toList = await List.findOne({ boardId: toBoard.id, name: fromList.name, }); if (!toList) { // Create the target list if it doesn't exist toList = await List.create({ boardId: toBoard.id, name: fromList.name, position: 0, }).fetch(); } const cards = await sails.helpers.lists.getCards(fromList.id); for (const card of cards.reverse()) { await sails.helpers.cards.updateOne.with({ record: card, values: { position: 0, project: toProject, board: toBoard, list: toList, }, project: fromProject, board: fromBoard, list: fromList, actorUser: user, }); } } })(); ```
Author
Owner

@maxsmooth commented on GitHub (Nov 14, 2024):

Hi! Yes, the structure has already been changed. Please try the following version:

No, there's still problems (user, from_board_id and to_board_id are correct, the script only creates first list and then stop, cards in the first list are not created):

Uncaught OperationalError [UsageError]: Could not run updateOne() because of a problem:
------------------------------------------------------
• Invalid "values":
  · Value ({
  position: 0,
  project: undefined,
  board: {
    id: '1378340230758663180',
    createdAt: 2024-11-13T11:55:59.665Z,
    updatedAt: null,
    position: 131070,
    name: 'pippo',
    projectId: '1378336384875496451'
  },
  list: {
    id: '1379057593376310937',
    createdAt: 2024-11-14T11:41:15.953Z,
    updatedAt: null,
    position: 0,
    name: 'Da valutare 🗃',
    boardId: '1378340230758663180'
  }
}) failed custom validation.
------------------------------------------------------

Please adjust your usage and try again.
 [?] See https://sailsjs.com/support for help.
    at REPL355:44:49
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error [UsageError]: Could not run updateOne() because of a problem:
  ------------------------------------------------------
  • Invalid "values":
    · Value ({
    position: 0,
    project: undefined,
    board: {
      id: '1378340230758663180',
      createdAt: 2024-11-13T11:55:59.665Z,
      updatedAt: null,
      position: 131070,
      name: 'pippo',
      projectId: '1378336384875496451'
    },
    list: {
      id: '1379057593376310937',
      createdAt: 2024-11-14T11:41:15.953Z,
      updatedAt: null,
      position: 0,
      name: 'Da valutare 🗃',
      boardId: '1378340230758663180'
    }
  }) failed custom validation.
  ------------------------------------------------------
  
  Please adjust your usage and try again.
   [?] See https://sailsjs.com/support for help.
      at REPL355:44:49
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    code: 'E_INVALID_ARGINS',
    problems: [
      'Invalid "values":\n' +
        '  · Value ({\n' +
        '  position: 0,\n' +
        '  project: undefined,\n' +
        '  board: {\n' +
        "    id: '1378340230758663180',\n" +
        '    createdAt: 2024-11-13T11:55:59.665Z,\n' +
        '    updatedAt: null,\n' +
        '    position: 131070,\n' +
        "    name: 'pippo',\n" +
        "    projectId: '1378336384875496451'\n" +
        '  },\n' +
        '  list: {\n' +
        "    id: '1379057593376310937',\n" +
        '    createdAt: 2024-11-14T11:41:15.953Z,\n' +
        '    updatedAt: null,\n' +
        '    position: 0,\n' +
        "    name: 'Da valutare 🗃',\n" +
        "    boardId: '1378340230758663180'\n" +
        '  }\n' +
        '}) failed custom validation.'
    ]
  },
  isOperational: true,
  code: 'E_INVALID_ARGINS',
  problems: [
    'Invalid "values":\n' +
      '  · Value ({\n' +
      '  position: 0,\n' +
      '  project: undefined,\n' +
      '  board: {\n' +
      "    id: '1378340230758663180',\n" +
      '    createdAt: 2024-11-13T11:55:59.665Z,\n' +
      '    updatedAt: null,\n' +
      '    position: 131070,\n' +
      "    name: 'pippo',\n" +
      "    projectId: '1378336384875496451'\n" +
      '  },\n' +
      '  list: {\n' +
      "    id: '1379057593376310937',\n" +
      '    createdAt: 2024-11-14T11:41:15.953Z,\n' +
      '    updatedAt: null,\n' +
      '    position: 0,\n' +
      "    name: 'Da valutare 🗃',\n" +
      "    boardId: '1378340230758663180'\n" +
      '  }\n' +
      '}) failed custom validation.'
  ]
}
@maxsmooth commented on GitHub (Nov 14, 2024): > Hi! Yes, the structure has already been changed. Please try the following version: No, there's still problems (user, from_board_id and to_board_id are correct, the script only creates first list and then stop, cards in the first list are not created): ``` Uncaught OperationalError [UsageError]: Could not run updateOne() because of a problem: ------------------------------------------------------ • Invalid "values": · Value ({ position: 0, project: undefined, board: { id: '1378340230758663180', createdAt: 2024-11-13T11:55:59.665Z, updatedAt: null, position: 131070, name: 'pippo', projectId: '1378336384875496451' }, list: { id: '1379057593376310937', createdAt: 2024-11-14T11:41:15.953Z, updatedAt: null, position: 0, name: 'Da valutare 🗃', boardId: '1378340230758663180' } }) failed custom validation. ------------------------------------------------------ Please adjust your usage and try again. [?] See https://sailsjs.com/support for help. at REPL355:44:49 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { cause: Error [UsageError]: Could not run updateOne() because of a problem: ------------------------------------------------------ • Invalid "values": · Value ({ position: 0, project: undefined, board: { id: '1378340230758663180', createdAt: 2024-11-13T11:55:59.665Z, updatedAt: null, position: 131070, name: 'pippo', projectId: '1378336384875496451' }, list: { id: '1379057593376310937', createdAt: 2024-11-14T11:41:15.953Z, updatedAt: null, position: 0, name: 'Da valutare 🗃', boardId: '1378340230758663180' } }) failed custom validation. ------------------------------------------------------ Please adjust your usage and try again. [?] See https://sailsjs.com/support for help. at REPL355:44:49 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 'E_INVALID_ARGINS', problems: [ 'Invalid "values":\n' + ' · Value ({\n' + ' position: 0,\n' + ' project: undefined,\n' + ' board: {\n' + " id: '1378340230758663180',\n" + ' createdAt: 2024-11-13T11:55:59.665Z,\n' + ' updatedAt: null,\n' + ' position: 131070,\n' + " name: 'pippo',\n" + " projectId: '1378336384875496451'\n" + ' },\n' + ' list: {\n' + " id: '1379057593376310937',\n" + ' createdAt: 2024-11-14T11:41:15.953Z,\n' + ' updatedAt: null,\n' + ' position: 0,\n' + " name: 'Da valutare 🗃',\n" + " boardId: '1378340230758663180'\n" + ' }\n' + '}) failed custom validation.' ] }, isOperational: true, code: 'E_INVALID_ARGINS', problems: [ 'Invalid "values":\n' + ' · Value ({\n' + ' position: 0,\n' + ' project: undefined,\n' + ' board: {\n' + " id: '1378340230758663180',\n" + ' createdAt: 2024-11-13T11:55:59.665Z,\n' + ' updatedAt: null,\n' + ' position: 131070,\n' + " name: 'pippo',\n" + " projectId: '1378336384875496451'\n" + ' },\n' + ' list: {\n' + " id: '1379057593376310937',\n" + ' createdAt: 2024-11-14T11:41:15.953Z,\n' + ' updatedAt: null,\n' + ' position: 0,\n' + " name: 'Da valutare 🗃',\n" + " boardId: '1378340230758663180'\n" + ' }\n' + '}) failed custom validation.' ] } ```
Author
Owner

@meltyshev commented on GitHub (Nov 14, 2024):

Oops, there was a typo when destructuring toProject, should be : instead of ,:

(async () => {
  const USER_EMAIL_OR_USERNAME = 'USERNAME_OR_EMAIL';
  const FROM_BOARD_ID = 'SOURCE_BOARD_ID';
  const TO_BOARD_ID = 'TARGET_BOARD_ID';

  const user = await sails.helpers.users.getOneByEmailOrUsername(USER_EMAIL_OR_USERNAME);
  if (!user) {
    console.error('User not found');
    return;
  }

  const {
    board: fromBoard,
    project: fromProject,
  } = await sails.helpers.boards.getProjectPath(FROM_BOARD_ID);

  const {
    board: toBoard,
    project: toProject,
  } = await sails.helpers.boards.getProjectPath(TO_BOARD_ID);

  const fromLists = await List.find({ boardId: fromBoard.id });
  if (fromLists.length === 0) {
    console.error('No lists found in the from board');
    return;
  }

  for (const fromList of fromLists) {
    let toList = await List.findOne({
      boardId: toBoard.id,
      name: fromList.name,
    });
    if (!toList) {
      // Create the target list if it doesn't exist
      toList = await List.create({
        boardId: toBoard.id,
        name: fromList.name,
        position: 0,
      }).fetch();
    }

    const cards = await sails.helpers.lists.getCards(fromList.id);
    for (const card of cards.reverse()) {
      await sails.helpers.cards.updateOne.with({
        record: card,
        values: {
          position: 0,
          project: toProject,
          board: toBoard,
          list: toList,
        },
        project: fromProject,
        board: fromBoard,
        list: fromList,
        actorUser: user,
      });
    }
  }
})();
@meltyshev commented on GitHub (Nov 14, 2024): Oops, there was a typo when destructuring `toProject`, should be `:` instead of `,`: ``` (async () => { const USER_EMAIL_OR_USERNAME = 'USERNAME_OR_EMAIL'; const FROM_BOARD_ID = 'SOURCE_BOARD_ID'; const TO_BOARD_ID = 'TARGET_BOARD_ID'; const user = await sails.helpers.users.getOneByEmailOrUsername(USER_EMAIL_OR_USERNAME); if (!user) { console.error('User not found'); return; } const { board: fromBoard, project: fromProject, } = await sails.helpers.boards.getProjectPath(FROM_BOARD_ID); const { board: toBoard, project: toProject, } = await sails.helpers.boards.getProjectPath(TO_BOARD_ID); const fromLists = await List.find({ boardId: fromBoard.id }); if (fromLists.length === 0) { console.error('No lists found in the from board'); return; } for (const fromList of fromLists) { let toList = await List.findOne({ boardId: toBoard.id, name: fromList.name, }); if (!toList) { // Create the target list if it doesn't exist toList = await List.create({ boardId: toBoard.id, name: fromList.name, position: 0, }).fetch(); } const cards = await sails.helpers.lists.getCards(fromList.id); for (const card of cards.reverse()) { await sails.helpers.cards.updateOne.with({ record: card, values: { position: 0, project: toProject, board: toBoard, list: toList, }, project: fromProject, board: fromBoard, list: fromList, actorUser: user, }); } } })(); ```
Author
Owner

@maxsmooth commented on GitHub (Nov 14, 2024):

Oops, there was a typo when destructuring toProject, should be : instead of ,:

Ok, thank you!

@maxsmooth commented on GitHub (Nov 14, 2024): > Oops, there was a typo when destructuring `toProject`, should be `:` instead of `,`: Ok, thank you!
Author
Owner

@madduck commented on GitHub (Jun 5, 2025):

I started work on plankacli precisely for such operations.

@madduck commented on GitHub (Jun 5, 2025): I started work on [plankacli](https://github.com/madduck/plankacli) precisely for such operations.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/planka#262