Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

When saving several pages from code, how to set default wokring page in cms 7.19

Vote:
 

Hi

we are saving pages from code but when looking in cms we can´t see the latest saved version

how do we set the latest saved version to default ?

thanks!


Regards
Pawel

#120280
Apr 14, 2015 15:49
Vote:
 

theres is a option in online center named "Setting the primary draft", but how to set it in code behind?

#120289
Apr 14, 2015 16:44
Vote:
 

IContentVersionRepository has a method SetCommonDraft.

#120293
Apr 14, 2015 17:05
Vote:
 

Thanks Per!

this is what i had to do:

producLink is my contentreference

var versionRepo = ServiceLocator.Current.GetInstance<IContentVersionRepository>();

var latestVersion = versionRepo.List(productLink).Last().ContentLink;

// get the last item in array

versionRepo.SetCommonDraft(latestVersion);

//set the last item as default

don't forget to use SaveAction.ForceCurrentVersion when saving

#120338
Apr 15, 2015 13:02
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.