Describe the problem/error/question
The problem is simple: I have tables in Notion with relational dependency. in Notion language: Linked databases: Using linked databases
In order to populate with POST API call, i need DB ID. you can imagine that if i want proper automation, spamming Notion to get the DB ID to route correctly is API heavy, time consuming and inneficient. Simple solution is to do it once in a sub flow and populate variable. unfortunately, global variables in N8N are only under PRO plan, costs of which i cant justify for what i need.
What is the error message (if any)?
you will get error 400, flow error that will complain about parent ID.
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to co{
"nodes": [
{
"parameters": {
"jsCode": "// Take normalized payload and fan out one item per position\nconst r = $input.first().json.received;\n\n// <-- put YOUR database id here -->\nconst DB_ID = 'X_Y_Z_ID';\n\nconst items = (r.positions || []).map(p => ({\n json: {\n dbId: DB_ID,\n asOf: r.asOf,\n platform: r.platform,\n account: r.accountLabel || '',\n currency: r.currency || '',\n symbol: (p.symbol || p.rawSymbol || '').toUpperCase(),\n name: p.name || '',\n qty: p.qty ?? null,\n avgCost: p.avgCost ?? null,\n lastPrice: p.lastPrice ?? null,\n value: p.value ?? null,\n pnl: p.pnl ?? null,\n // Notion \"percent\" wants decimals (0.25 for 25%)\n pnlPctDecimal: (p.pnlPct == null ? null : Number(p.pnlPct) / 100)\n }\n}));\n\nreturn items;\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
400,
-144
],
"id": "censorship applied",
"name": "Prep Items"
},
{
"parameters": {
"method": "POST",
"url": "https://api.notion.com/v1/pages",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "notionApi",
"sendBody": true,
"contentType": "raw",
"rawContentType": "JSON (application/json)",
"body": "={{ \n JSON.stringify({\n parent: { type: \"database_id\", database_id: $json.dbId },\n properties: {\n \"Ticker\": { title: [{ text: { content: $json.symbol } }] },\n \"OS/ As Of\": { date: { start: $json.asOf } },\n \"OS/ Platform\": { rich_text: [{ text: { content: $json.platform || \"\" } }] },\n \"OS/ Account\": { rich_text: [{ text: { content: $json.account || \"\" } }] },\n \"OS/ Currency\": { rich_text: [{ text: { content: $json.currency || \"\" } }] },\n \"OS/ Qty\": { number: $json.qty ?? null },\n \"OS/ Avg Cost\": { number: $json.avgCost ?? null },\n \"OS/ Last Price\": { number: $json.lastPrice ?? null },\n \"OS/ Value\": { number: $json.value ?? null },\n \"OS/ P/L\": { number: $json.pnl ?? null },\n \"OS/ P/L%\": { number: $json.pnlPctDecimal ?? null }\n }\n })\n}}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
624,
-144
],
"id": "bd227741-590f-48bb-aec2-eee883524962",
"name": "HTTP (Page Creation)",
"credentials": {
"notionApi": {
"id": "SH22k3ZejUisCD7e",
"name": "Notion account 2"
}
}
}
],
"connections": {
"Prep Items": {
"main": [
[
{
"node": "HTTP (Page Creation)",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "885effde3483a0b2ee84c6ff345c166eaa425e59d0566252a358b27363e816ba"
}
}py and paste the workflow.)
Share the output returned by the last node
Information on your n8n setup
- n8n version: latest stable 1.6xxx
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):n8n cloud
- Operating system: win11
