The Page data type is specific to database properties that allow for other Notion to be selected or displayed, such as the Relation, Rollup, and Formula properties. When dealing with a Page data type, you can utilise the built-in Created By, Created Time, Last Edited By, and Last Edited Time properties.
prop("Created By") /* Output: "🧔🏻♂️ Thomas Frank" */
prop("Created Time") /* September 14, 2023 10:04 AM */
prop("Last Edited By") /* Output: "🧔🏻♂️ Thomas Frank" */
prop("Last Edited Time") /* September 14, 2023 12:59 PM */
Code language: JavaScript (javascript)
You can also use the id
function directly.
Accessing a Related Page’s Properties
Once you have a Page data type to work with, you’ll be able to reference its own page properties directly. Let’s assume we have a Relation property with at least one page related. As pages in a relation property are listed in an array, the first example uses first
to return only the first page, while the second example uses map
to return a list of the Created By values for each page.
prop("Relation").first().prop("Created By")
/* Output: "Thomas Frank" */
prop("Relation").map(current.prop("Created Time"))
/* Output: ["@September 14, 2023 10:04 AM", "@September 12, 2023 09:17 PM"] */
Code language: PHP (php)
Once again, the id
function can be used to return the unique page ID of the related pages.
prop("Relation").first().id()
/* Output: "6f65542cde7b4c548155474684281d15" */
prop("Relation").map(current.id())
/* Output: ["6f65542cde7b4c548155474684281d15", "781a4fd8e8f243828872c6a5b21d7d0c"] */
Code language: CSS (css)