Getting Page relative URL from GUID

Stuart1 Freeman1 asked on January 14, 2020 22:57

Hi All,

I have a custom menu item type with a PageUrl field of Data type Text which uses the Page Selector Form control. This returns a Guid string when I query it.

Is there is smart way I can have the DocumentQuery return the actual relativeURL for the page rather than the Guid? I will change my code/field type provider query whatever way needed to facilitate having the relative URL.


Correct Answer

Sean Wright answered on January 15, 2020 04:40


Do you mean you want the Page Selector Form Control to return the path instead of the Guid?

That control doesn't work that way, so if you wanted that behavior you'd have to create your own custom Form Control. You could try copying the existing one and start from there.

If you did have it insert something like the NodeAliasPath of the selected page, what would happen if the page was moved or renamed? In these cases, having the Guid value is safer since you can always look up the 'current NodeAliasPath' from the Guid.

Side note: You can change the value of the custom Page Type field to Unique identifier and still use the Page Selector Form Control so that you don't have to convert the string value to Guid in your code.

1 votesVote for this answer Unmark Correct answer

Recent Answers

Stuart1 Freeman1 answered on January 15, 2020 17:43

Hi Sean, came to the above conclusion last night and kept my implementation exactly as you describe. Was trying to avoid the additional query, grabbing the nodeAliasPath for the links.

I have a related question - Is there a way to grab all documents that are children/grandchildren/great-grandchildren of a document given it's NodeGuid or NodeAliasPath? Thanks!

0 votesVote for this answer Mark as a Correct answer

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