Note that there are some explanatory texts on larger screens.

plurals
  1. POGet a Sitecore item from the master DB that is the version that would be published if the site was published now
    primarykey
    data
    text
    <p>I am working on a data export from Sitecore, from the master database. It gets data from items of a certain type and puts it into custom XML. I am able to generate the XML I need but now the client has asked that instead of returning data from the most recent version it return data from the version that would be published if the site was published at the time the export was performed. </p> <p>The nature of the site is that it must be published on a regular but infrequent basis (once a year, I believe) but the data will be maintained continuously and anything approved in Sitecore needs to be added to another system, so doing the export from the web database is not an option, unfortunately. I am hoping to hook into whatever mechanism Sitecore uses to decide which version goes to the Web DB when/if publishing happens without actually publishing.</p> <p>I have looked at <code>Item.Publishing.GetValidVersion</code>, <code>IsValid</code>, and <code>IsPublishable</code> but have been unsuccessful in putting them to use. I have read the Sitecore docs for those methods but the description just says "Gets the valid version." and I am not sure what it means by "valid". </p> <p>Here is my latest attempt:</p> <pre><code>foreach (Sitecore.Data.ID courseId in courseIds) { Sitecore.Data.Items.Item course = master.GetItem(courseId); string initialVersion = course.Version.ToString(); if (course != null &amp; course.Parent.Name != "Narrative-Courses") { course = course.Publishing.GetValidVersion(DateTime.Now, true, true); string finalVersion = course.Version.ToString(); if (initialVersion != finalVersion) { log(course.Name + ": " + initialVersion + ", " + finalVersion); } if (course != null) { //add xml for this item ... </code></pre> <p>My log is blank and my XML includes the highest number version of each item, regardless of workflow state. When an item has version 1 in an Approved state and version 2 in a Draft state, I only get version 2 in the XML.</p> <p>Am I misinterpreting what those methods are for or just misusing them?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload