Hi, Im trying to pre-populate certain fields of a document type based on its parents to avoid re-typing them. i.e: Region (Parent) has the following fields populated Country and Region name. It's child Shop must have his field region qnd country pre-populated when creating a new shop based on the info found on it's parent.
I've tried achieving this result with the following Macro : {% CMSContext.CurrentDocument.Parent.GetValues("CountryName") %} or {% DocumentContext.CurrentDocumentParent.GetValue("CountryName") %} But both failed.
{% CMSContext.CurrentDocument.Parent.GetValues("CountryName") %} or {% DocumentContext.CurrentDocumentParent.GetValue("CountryName") %}
Hello,
you should be able to access the parent object on the Form tab as:
EditedObject.Parent.Field
or parent of parent like:
EditedObject.Parent.Parent.Field
Best regards, Jan Hermann
Why would you need that populated if its already defined in the hierarchy? Depending on what version you are using it will vary what you use. Also, when are you attempting to populate this data?
Hi Brenden,
My goal is to populate the Location field of the Google Basic Maps based on a concatenation of both the parent node property and the child. Because in my scenario the GPS coordinates are not all the time available. Unfortunately this approach sseems not to be the best .May you find below the recommendation from the support team
Unfortunately this approach will not work because the macro is not resolved in the context of the current document and also its resolved before the document is created. There is another approach - You can create a global event -> Document.Insert.After which would automatically set your field to a parent name. You would get the parent node form the NodeParentID property of the edited object.
Its quite easy to accomplish - please see following article about global events. It also features a simple example from which you can inspire: docs.kentico.com/display/K8/Handling+global+events
Please, sign in to be able to submit a new answer.