API
Version 7.x > API > Versioning for instance of custom document type View modes: 
User avatar
Member
Member
poplooukhin-gmail - 2/25/2014 4:08:33 PM
   
Versioning for instance of custom document type
Hi, all

I created a new instance of custom document type using Kentico API.
After that, I try to get a version of this document:
string where = "VersionObjectID =" + treeNode["DocumentID"];
//using treeNode["NodeID"] does not result for me too
string orderBy = "VersionModifiedWhen DESC";
int topN = 1;


DataSet versionDS = ObjectVersionHistoryInfoProvider.GetVersionHistories(where, orderBy, topN, null);

if (!DataHelper.DataSourceIsEmpty(versionDS))
{
// Get version
ObjectVersionHistoryInfo version = new ObjectVersionHistoryInfo(versionDS.Tables[0].Rows[0]);
return version.VersionNumber;
}

return string.Empty;


But I get version "1.1" instead of "0.1". If I update document (I can see a new values in updated document), then I will get version "1.1" instead of 1.1 + 0.1.

I always get version 1.1

I set:
"Version history length (major versions)" to 0
"Version history length (major versions)" to 0
"Save to last version if younger than (minutes)" to 0
"Promote to major version if older than (hours)" to 24

Please, give me a sample code for getting version of instance of custom document type.

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/27/2014 1:41:34 AM
   
RE:Versioning for instance of custom document type
Hello,

The ObjectVersionHistoryInfoProvider is only for objects and contains just general version of that document type (not document versions), so please use the VersionHistoryInfoProvider instead:

string where = "DocumentID = 5";
string orderBy = "ModifiedWhen ASC";
int topN = 1;

DataSet versionHistory = VersionHistoryInfoProvider.GetVersionHistories(where, orderBy, topN, null);


Best regards,
Jan Hermann