From fa10376beabf4941529e7b08c88065048507a6e3 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 23 Jul 2024 10:21:09 +0200 Subject: [PATCH] fix: refs #7662 assign --- back/methods/collection/assign.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/back/methods/collection/assign.js b/back/methods/collection/assign.js index 0484eb5a8..9abeb46f5 100644 --- a/back/methods/collection/assign.js +++ b/back/methods/collection/assign.js @@ -20,9 +20,13 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const [, , [{collectionFk}]] = - await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk', - [userId], myOptions); + const result = await Self.rawSql(` + CALL vn.collection_assign(?, @vCollectionFk); + SELECT @vCollectionFk collectionFk + `, [userId], myOptions); + + // Por si entra en el SELECT FOR UPDATE y retorna un array más + const collectionFk = result[2][0]?.collectionFk || result[3][0]?.collectionFk; if (!collectionFk) throw new UserError('There are not picking tickets'); await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);