I have a page which has "Title" property:
CurrentPage["Title"] is has value - "Test";
When I change "Title" property to "AnotherTest" and click Save and view button in edit mode, the change is reflected on the page.
CurrentPage["Title"] is "AnotherTest"
But when I'm using this (current page is with id 6):
PageReference pageRef = new PageReference(6);
PageData pageData = GetPage(pageRef)
pageData["Title"] is still equal to "TestTitle"
Is there a way to get the modified property through GetPage() method?
When you are retrieving the page like that (with GetPage) you are getting the published version, but when you are using CurrentPage (in that situation) you are getting the version that you are currently viewing. The solution to your problem is dependent on what you are trying to do, but maybe this is a none-issue as it will work when the page is published?
If you need the last saved version something like this should work (though there might be a better way):
PageVersion lastSavedVersion = DataFactory.Instance.ListVersions(new PageReference(6)).OrderByDescending(version => version.Saved).First(); PageData lastSavedPageData = DataFactory.Instance.GetPage(lastSavedVersion.ID);
Just to clearify, the problem is in the line:PageReference pageRef = new PageReference(6);
When you create a new PageReference with just a pageId in the constructor, you will automatically get the published version. And since you stated you only clicked Save and View you are not publishing the new version.
So what you can do is either specify the version:PageReference pageRef = new PageReference(6, XXX);PageData pageData = GetPage(pageRef);
Or do the really long walk with CurrentPage:PageReference pageRef = new PageReference(CurrentPage.PageLink);PageData pageData = GetPage(pageRef);
Or do the short walk:PageData pageData = CurrentPage;
Because CurrentPage always uses the page version if it can...
Best regardsFredrik KarlssonDropit