need to get parent value on pag type field

Kaushik Patel asked on April 8, 2019 15:28

I have created page type called Hospitals and doctors. My page structures as following: 1. Hospitals Folder 2. Many hospitals under it 3. Each hospital had Doctors folder 4. Doctors Folder contains many doctors. So i have to get hospital name on doctors page type field. How can i get it? I have tried to get currentdocment but when i create the doctors page, it is empty.

so please let me know how can i achieve?

Correct Answer

Juraj Ondrus answered on April 9, 2019 10:53

You need to keep in mind what context you have available. On the Form tab, you have only the context from the iFrame URL query string parameters available: CMSModules/Content/CMSDesk/Edit/edit.aspx?nodeid=<NODEID>&culture=<CULTURECODE> so you need to work with these data only. There is no current document context available.
So, you need to get the parent node ID at first - EditedObject.NodeParentID and then using this ID you will need to create a macro which will get the data you want. Something like (just a quick idea): {%Documents[Documents.Where("NodeID = '"+EditedObject.NodeParentID+"'").FirstItem.NodeAliasPath].DocumentName|(identity)GlobalAdministrator%}

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on April 8, 2019 15:38 (last edited on December 10, 2019 02:31)

Using the {%CurrentDocument%} object in a page type field doesn't work because the {%CurrentDocument%} context is only available in the edit or live views. In this case you might want to try {%EditedObject.Parent.DocumentName|(identity)GlobalAdministrator%}. This way the value is not stored with the page type.

0 votesVote for this answer Mark as a Correct answer

Kaushik Patel answered on April 9, 2019 06:43 (last edited on December 10, 2019 02:31)

I have tried to use {%EditedObject.Parent.DocumentName|(identity)GlobalAdministrator%} but did not get any details. please provide other ways. because i need to save that parent field value as foreign key in child page type.

0 votesVote for this answer Mark as a Correct answer

Kaushik Patel answered on April 9, 2019 07:44

i want to save parent node reference in page type fields. because i have parent child relation ship for hospitals, doctors for specific hospital, Packages for the hospitals. Currently i have created doctors and packages folder under website, and added drop down to select the hospital. But in other culture language, it quite difficult to search the hospital in long drop down list. so please provide the way to achieve this functionality.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.