How to Add a Step in Workflow to Fill Out a "Relation" Type Property in Notion?

This topic was automatically generated from Slack. You can find the original thread here.

how can I add a step in my workflow wherein it can fill out a property in Notion that is a “Relation” type property?

To fill out a property in Notion that is a “Relation” type property, you can use the “Update Page” action in your Pipedream workflow. Here’s how to do it: 1. Search for the Notion app from the step menu 2. Select the Update Page action 3. Connect your Notion account 4. Select a Page ID or pass a string from a previous step. 5. At the bottom of the step, click Test to run the action and test the configuration. In the optional props, you can configure the Property Types and Property Types Values fields to update the “Relation” type property. Make sure to pass the correct values for these fields. Remember to visit the Notion app documentation for more details: https://pipedream.com/apps/notion/actions/update-page

I can’t see the property when I’m trying to configure the property types. This workflow will create a new notion page. Is there a python code I can use to add and fill out the “Relation” property in Notion?

I understand that you’re trying to create a new Notion page and fill out a “Relation” type property. However, Pipedream currently supports Node.js for component code. If you’re open to using Node.js, I can help you create a custom code step to achieve this. First, you’ll need to use the Notion API to create a new page and update the “Relation” property. Here’s an example of how you can do this using Node.js in a Pipedream workflow: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { notionApiKey: { type: "string", label: "Notion API Key", secret: true, }, databaseId: { type: "string", label: "Notion Database ID", }, relatedPageId: { type: "string", label: "Related Page ID", }, relationPropertyName: { type: "string", label: "Relation Property Name", }, }, async run({ $ }) { const headers = { "Notion-Version": "2022-06-28", "Content-Type": "application/json", "Authorization": `Bearer ${this.notionApiKey}`, }; // Create a new page const createPageResponse = await axios($, { method: "POST", url: "https://api.notion.com/v1/pages", headers, data: { "parent": { "database_id": this.databaseId }, "properties": {} } }); const newPageId = createPageResponse.id; // Update the Relation property await axios($, { method: "PATCH", url: `https://api.notion.com/v1/pages/${newPageId}`, headers, data: { "properties": { [this.relationPropertyName]: { "relation": [ { "id": this.relatedPageId } ] } } } }); return { newPageId }; }, }); Replace the notionApiKey, databaseId, relatedPageId, and relationPropertyName with the appropriate values. This code will create a new page in the specified database and update the “Relation” property with the related page ID. Please note that this code uses Node