Wonder Is it possible to make changes to a notion date property when a certain other date properties are updated?
For instance, when Start & End properties are not empty, can I add the same value as a complete Date Range to another Start-End date property in the same page ?
I’ve noticed that the Updated Page in Database trigger seems to keep showing ‘Unknown configuration error’ no matter how many times I tried :
refreshing fields or
selecting other Database ID or
clicking ‘create source’
In the meantime, I just happened to come across a similar post. May I also have Pipedream workflow instructions including a simplified example of how I might write a custom code step in Node.js to check those properties and update another property within each page and same database if the condition is met?
Any prompt and detailed response would be greatly appreciated.
Based on your description, it sounds like you’re encountering an issue with the Updated Page in Database trigger and you’re looking for a way to programmatically update a Notion date property when other date properties change. While I cannot directly troubleshoot the trigger issue without more information, I can certainly help you with a custom code step to check and update Notion properties.
Here’s a simplified example of how you might write a custom Node.js code step to check the Start and End properties and update the Start-End date property on the same page if both are not empty:
import { axios } from "@pipedream/platform";
export default defineComponent({
props: {
notion: {
type: "app",
app: "notion",
},
},
async run({ steps, $ }) {
// Replace with your actual database ID and page ID
const databaseId = "your-database-id";
const pageId = "your-page-id";
// Fetch the page properties
const page = await axios($, {
method: "GET",
url: `https://api.notion.com/v1/pages/${pageId}`,
headers: {
Authorization: `Bearer ${this.notion.$auth.oauth_access_token}`,
"Notion-Version": "2021-08-16",
},
});
// Check if Start and End properties are not empty
const startProperty = page.properties["Start"];
const endProperty = page.properties["End"];
if (startProperty && endProperty) {
// Update the Start-End date property
await axios($, {
method: "PATCH",
url: `https://api.notion.com/v1/pages/${pageId}`,
headers: {
Authorization: `Bearer ${this.notion.$auth.oauth_access_token}`,
"Notion-Version": "2021-08-16",
"Content-Type": "application/json",
},
data: {
properties: {
"Start-End": {
date: {
start: startProperty.date.start,
end: endProperty.date.end,
},
},
},
},
});
}
},
});
Please replace "your-database-id" and "your-page-id" with the actual IDs of your Notion database and page. This code assumes that the Start and End properties
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double-check my answers and code! Learn how to build your own.
Thanks. However, Instead of only certain page-id, I wonder what if I want Start-End date property of every page in the same database also be automatically detected and updated when other Start & End date properties change?