Thanks Dave & Lee, I did do some experimenting and could only get back empty Guids, but useful to know it's not yet possible.
Am thinking of making a 'Hidden Guid' package which could be configured either write a new Guid (and it never changes) or the current version Guid into a hidden field. (The hidden new Guid has been useful to identify nested content / stacked content items)
@Sebastiaan, it's for a questionnaire app, where questions and answers are Umbraco nodes, and submissions are logged to a database storing keys. We use the version key (rather than the regular key) so we can determine the exact copy of the question / answer asked at the time that submission was made.
Gotcha. I think the idea is good, but it seems a bit fragile once someone starts using UnVersion to remove those pesky old versions.
Personally I would just store both the question and the answer (yes, I realize I used the word "just" ;-) ).
It seems like the version attribute is an implementation detail that should be an internal property that shouldn't be exposed publicly. I think if you really want to you can use the contentservice to find it instead.
Version Guid for IPublishedContent
Hi,
Is it possible to get at the current Version Guid for content via IPublishedContent without hitting the database ?
Thanks, Hendy
Hi Hendy,
I see the IPublisedContent interface has a Version property that is of type guid : https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Core/Models/IPublishedContent.cs#L59
Have you tried that ?
Looking at the code of XmlPublishedContent it doesn't seem to hit the db to populate this : https://github.com/umbraco/Umbraco-CMS/blob/7ee510ed386495120666a78c61497f58ff05de8f/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs#L329
Dave
Although
XmlPublishedContent
is set-up to accept the "version" attribute (from the XML node), it doesn't appear to be there!Here's the XML serialization code for
IContent
: https://github.com/umbraco/Umbraco-CMS/blob/release-7.10.1/src/Umbraco.Core/Services/EntityXmlSerializer.cs#L33Interesting the version has been added for
IMedia
: https://github.com/umbraco/Umbraco-CMS/blob/release-7.10.1/src/Umbraco.Core/Services/EntityXmlSerializer.cs#L75I'm thinking the best place to add it is for the shared
IContentBase
serialization? e.g. https://github.com/umbraco/Umbraco-CMS/blob/release-7.10.1/src/Umbraco.Core/Services/EntityXmlSerializer.cs#L478In answer to your original question Hendy, nope - it's unfortunately looking like an extra database hit.
Cheers,
- Lee
I think this is a up for grabs PR :-) Who is gonna report the issue ?
Dave
Please be my guest :-) I've gotta get lunch now anyway.
Hmmm. Is the search on the Issue Tracker working for anyone else? http://issues.umbraco.org/issues/U4?q=Version
Nope not working..Noticed this as well today : https://twitter.com/dawoe21/status/982187087922212864
Done : http://issues.umbraco.org/issue/U4-11186
Search is not working for me either.
Thanks Dave & Lee, I did do some experimenting and could only get back empty Guids, but useful to know it's not yet possible.
Am thinking of making a 'Hidden Guid' package which could be configured either write a new Guid (and it never changes) or the current version Guid into a hidden field. (The hidden new Guid has been useful to identify nested content / stacked content items)
@Hendy - small note from the sidelines, each NC & SC item already has a GUID "key" property available ... or are you needed something different?
@Lee, ooh I didn't know they had keys, I'll take a look again, thanks
What is it that you want to use the version for?
Will probably use this in combination with the new constent API, so you can log which version of terms the user agreed with.
Dave
@Sebastiaan, it's for a questionnaire app, where questions and answers are Umbraco nodes, and submissions are logged to a database storing keys. We use the version key (rather than the regular key) so we can determine the exact copy of the question / answer asked at the time that submission was made.
Gotcha. I think the idea is good, but it seems a bit fragile once someone starts using UnVersion to remove those pesky old versions.
Personally I would just store both the question and the answer (yes, I realize I used the word "just" ;-) ).
It seems like the version attribute is an implementation detail that should be an internal property that shouldn't be exposed publicly. I think if you really want to you can use the contentservice to find it instead.
I stumbled over the same issue and can't find the issue in the Github issue tracker. Has this issue been solved in the meantime?
is working on a reply...