Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0 become 1 #9126

Open
lucalamo opened this issue Apr 11, 2024 · 4 comments
Open

0 become 1 #9126

lucalamo opened this issue Apr 11, 2024 · 4 comments

Comments

@lucalamo
Copy link

Bug Description

Set node trasform 0 in 1 only in visual, the following code node with console log print 0 correctly.
If I press test button twice, its print 0 correctly...
image

To Reproduce

watch screenshot

Expected behavior

zero remain zero

Operating System

ubuntu 22.04

n8n Version

1.36.1

Node.js Version

v18.17.1

Database

PostgreSQL

Execution mode

main (default)

@lucalamo
Copy link
Author

Its always print 1 with the following expression {{ $json.Qty.toString() }}

@Joffcom
Copy link
Member

Joffcom commented Apr 11, 2024

Hey @lucalamo,

That is interesting, I am not able to reproduce this.

image

Can you try the workflow below and let me know if that has the same issue?

{
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "8c8c5237b8e37b006a7adce87f4369350c58e41f3ca9de16196d3197f69eabcd"
  },
  "nodes": [
    {
      "parameters": {},
      "id": "f226f6f5-964b-4845-a66b-297873d33a51",
      "name": "When clicking \"Test workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        820,
        340
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "bfe82f54-5cc0-4188-9e5e-a5a46b63a8c4",
              "name": "Qty",
              "value": "={{ $json.Qty }}",
              "type": "number"
            },
            {
              "id": "dfc373ca-f74e-4777-bc10-95742e2aee39",
              "name": "Test",
              "value": "={{ $json.Qty.toString() }}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "0a3ff0b4-229b-4f31-81eb-464b9bf66160",
      "name": "Edit Fields1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        1260,
        340
      ]
    },
    {
      "parameters": {
        "jsCode": "return [\n  {\n    \"Id\": 1874,\n    \"Qty\": 0\n  }\n]"
      },
      "id": "8ed64f70-d107-409c-87d7-3bd9f1a05ebb",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1040,
        340
      ]
    }
  ],
  "connections": {
    "When clicking \"Test workflow\"": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {}
}

@lucalamo
Copy link
Author

lucalamo commented Apr 11, 2024

I found the problem: its compare dataset fault: it change the previous set edits fields output

{
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "2dfd12ee6c242e44e758a59efc40883b1fdf080a10bf3300a00c76f076aa13d1"
  },
  "nodes": [
    {
      "parameters": {},
      "id": "0b73d39f-8c42-48c7-9dfb-19ed09a6bd11",
      "name": "When clicking \"Test workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        240,
        320
      ]
    },
    {
      "parameters": {
        "mergeByFields": {
          "values": [
            {
              "field1": "Sku",
              "field2": "Sku"
            },
            {
              "field1": "Mag",
              "field2": "Mag"
            }
          ]
        },
        "resolve": "mix",
        "fuzzyCompare": true,
        "exceptWhenMix": "Qty,Date",
        "options": {
          "skipFields": "Id,Date"
        }
      },
      "id": "d26898df-2d7c-4352-803c-7bae8eabd705",
      "name": "Compare Datasets",
      "type": "n8n-nodes-base.compareDatasets",
      "typeVersion": 2.3,
      "position": [
        1040,
        340
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "140f142e-ae44-4e6f-b739-f1724bcf9714",
              "name": "Qty",
              "value": "={{ $json[\"Quantita disponibile\"] }}",
              "type": "string"
            },
            {
              "id": "6cc90a81-0ba9-44f7-bd2d-3118b3b3a20e",
              "name": "Sku",
              "value": "={{ $json.codice_a_barre }}",
              "type": "string"
            },
            {
              "id": "540c819c-441f-413f-ba67-160ab97ae28b",
              "name": "Mag",
              "value": "=BER_{{ $json.Filiale }}",
              "type": "string"
            },
            {
              "id": "dee32f37-d325-4b62-a7f4-167f449e7c42",
              "name": "Date",
              "value": "={{ $json.Data_ult_acq }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "113335ef-589e-4976-9df0-db0d50dd0ded",
      "name": "Edit Fields2",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        740,
        420
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Add a new field called 'myNewField' to the JSON of the item\nconsole.log($input.item.json)\nreturn $input.item;"
      },
      "id": "ad979617-a37e-4283-bd8d-86642f8fae7b",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        900,
        160
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "3ed82b1c-d4e7-49ab-b00e-31a7d77d2dbf",
              "name": "Sku",
              "value": "={{ $json.nc_7zl7__Variants_id }}",
              "type": "string"
            },
            {
              "id": "3561284d-a9ef-4fdb-8aa4-ba4c584df991",
              "name": "Mag",
              "value": "={{ $json.nc_7zl7___Warehouses_id }}",
              "type": "string"
            },
            {
              "id": "92693673-ca8b-4462-8597-84816ea7658d",
              "name": "Date",
              "value": "={{ $json.LastPurchaseDate }}",
              "type": "string"
            },
            {
              "id": "46d4b2a6-b8a1-42f1-9848-5dd554abd88c",
              "name": "Qty",
              "value": "={{ $json.Qty.toString() }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "include": "selected",
        "includeFields": "Id",
        "options": {}
      },
      "id": "fbe45da1-3e99-4bf9-a765-a9ce82632318",
      "name": "Edit Fields4",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        740,
        240
      ]
    },
    {
      "parameters": {},
      "id": "0cef60ef-2a02-48d0-b13f-490f21ce25c7",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        520,
        240
      ]
    },
    {
      "parameters": {},
      "id": "528b412d-5e5b-4ab9-9c31-c6f46cca8782",
      "name": "No Operation, do nothing1",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        520,
        420
      ]
    }
  ],
  "connections": {
    "When clicking \"Test workflow\"": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          },
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "Compare Datasets",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Edit Fields4": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          },
          {
            "node": "Compare Datasets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Operation, do nothing": {
      "main": [
        [
          {
            "node": "Edit Fields4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Operation, do nothing1": {
      "main": [
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {
    "No Operation, do nothing": [
      {
        "Id": 18274,
        "Qty": 0,
        "nc_7zl7__Variants_id": "889652420233",
        "nc_7zl7___Warehouses_id": "BER_A",
        "LastPurchaseDate": "2023-04-17"
      }
    ],
    "No Operation, do nothing1": [
      {
        "Filiale": "A",
        "Magazzino_Logico": "01",
        "Categoria": "0",
        "Tipo_prodotto": "Montature vista",
        "Fornitore": "Kering Eyewear",
        "marchio": "Saint Laurent",
        "linea": "Saint Laurent",
        "Modello": "SL 571 OPT",
        "Colore": "003 havana havana transpa",
        "Calibro": "49",
        "Ponte": "22",
        "Rb2": "0",
        "Addizione": "0",
        "codice_a_barre": "889652420233",
        "codice_articolo": "7VC14NL0A",
        "Tipo lenti": "Vista",
        "Utente": "unisex",
        "Materiale": "acetato riciclato",
        "Prezzo_Acquisto": "112,2",
        "Giacenza": "1",
        "Data_ult_acq": "17/04/2023ee",
        "Prezzo_Vendita": "355",
        "Sku": "30014071003",
        "asta": "145",
        "Prezzo consigliato": "355",
        "Quantita prenotata": "0",
        "Quantita disponibile": "1",
        "Prezzo listino acquisto": "132",
        "Prezzo saldo": "0",
        "Prezzo listino acquisto export": "132",
        "prezzo listino acquisto ultimo carico": "132"
      }
    ]
  }
}

image

image

@Joffcom
Copy link
Member

Joffcom commented Apr 11, 2024

Hey @lucalamo,

That reproduces it, Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants