Seeking Advice on Pre-Filling Property Values in U...
# help-with-umbraco
r
Hi all! I'm currently working on implementing a website in Umbraco 13 for a client, and I've encountered a specific requirement that I'm unsure how to best implement. The client has a content structure where categories can have products as sub-nodes. The root node (category) contains properties that should also be present at the product level. For example, if the category has a property called "color" with the value "red," this value should be pre-filled for the "color" property of the products under that category. However, it should still be possible to edit the value at the product level. Has anyone dealt with this use case before or knows the best way to implement this in Umbraco 13? I considered using a NotificationHandler, such as "ContentPublishedNotification," to pre-fill the fields if they are not already filled in. However, this approach seems suboptimal as it requires the content to be saved first before the pre-filled values are visible to the client. Any insights or suggestions would be greatly appreciated! Thanks in advance!
r
To be clear, are the categories and products present as separate documents in the tree, or are they in a single document as a nested content property? If the former, you could potentially use fallback values (specifically fallback to ancestors): https://docs.umbraco.com/umbraco-cms/v/13.latest-lts/reference/querying/ipublishedcontent/properties#fallbacks While these don't pre-populate the properties, they do allow you to say that the property is specified elsewhere. You could potentially add a note to the property description to say that this is what would happen if the field is left empty.
r
Hi, first of all, thanks for your fast reaction! The categories and products are presented as separate documents in the tree, and both have their own document types. I’m looking for a solution where certain properties of a product can be linked to or pre-filled based on properties of its parent category. The fields of a category are not 1:1 with the product, so the product can also have its own unique properties. However, it would be beneficial if some properties at the product level could be pre-filled based on the category. Any suggestions on how to achieve this would be greatly appreciated!
8 Views