SaaS CMS has officially launched! Learn more now.

CreateWritableClone in PageStoreService webservice


Hi all!

I am updating product-pages from inriver PIM and I want to publish a new version of a page through PageStoreService webservice but I am not sure how to do that. The method GetDefaultPageData creates a new page and that’s not what I want to do and I can't find anything close to CreateWritableClone. Does anyone know how I can do that? 

Thank you in advance.



Edited, Aug 17, 2016 17:57

You should be able to call GetPage first, update the properties you want to update, and then call Save.

Aug 18, 2016 14:51

Yes I know. But the changes are not published directly to the site. The changes are there if I look at the page via the CMS but on the site it isn't updated. I have to publish the page manually. 

Aug 18, 2016 14:57

To do that you need to supply the optional parameter to the save method:
_contentRepository.Save(content, SaveAction.Publish);

If that doesn't work, mostly if you run this from a stand alone job, try with the last parameter too:

_contentRepository.Save(content, SaveAction.Publish, AccessLevel.NoAccess);

Aug 18, 2016 16:21

That is exactly what I am trying to do:

epi.Save(languageBranch, SaveAction.Publish, AccessLevel.NoAccess); 

But I get an error message:

15:35:51 - Information  Something went wrong with saving page: PimSysId = 595578. Message: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK_tblContentLanguage'. Cannot insert duplicate key in object 'dbo.tblContentLanguage'. The duplicate key value is (31359, 1).

   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)

   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)

   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite)

   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)

   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)

   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()

   at EPiServer.DataAccess.ContentSaveDB.CreateContentVersion(IContent content, Boolean isNew, String currentUser)

   at EPiServer.DataAccess.ContentSaveDB.CreateAndSave(IContent content, Boolean delayPublish, Boolean forceCurrentVersion, Boolean forceNewVersion, String currentUser)

   at EPiServer.DataAccess.ContentSaveDB.<>c__DisplayClass16.<SaveInternal>b__15()

   at EPiServer.Data.Providers.SqlDatabaseHandler.<>c__DisplayClass4.<ExecuteTransaction>b__3()

   at EPiServer.Data.Providers.SqlDatabaseHandler.<>c__DisplayClass7`1.<ExecuteTransaction>b__6()

   at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)

   at EPiServer.DataAccess.ContentSaveDB.SaveInternal(IContent content, SaveAction action, Nullable`1 delayPublishUntil, String currentUser)

   at EPiServer.DataAccess.ContentSaveDB.Save(IContent content, SaveAction action, String currentUser)

   at EPiServer.DataAbstraction.ContentStore.Save(IContent content, SaveAction action, String currentUser)

   at EPiServer.DefaultContentProvider.Save(IContent content, SaveAction action)

   at EPiServer.Core.DefaultContentRepository.Save(IContent content, SaveAction action, AccessLevel access)

   at EPiServer.WebServices.PageStoreService.Save(RawPage page, SaveAction action, AccessLevel access)

   --- End of inner exception stack trace ---

Aug 18, 2016 16:47

It works fine if I use: 

epi.Save(languageBranch, SaveAction.ForceCurrentVersion, AccessLevel.NoAccess); 

Aug 18, 2016 16:48

That is why I think I need to create a clone of the page so that I can publish the page and see if the page on the site is updated without having to manually publishing it. But I am not sure how to do that in the PageStoreService.

Aug 18, 2016 16:53

And if you do this?

epi.Save(languageBranch, SaveAction.ForceCurrentVersion, AccessLevel.NoAccess); 

epi.Save(languageBranch, SaveAction.Publish, AccessLevel.NoAccess); 

Aug 18, 2016 17:22

I will try it and get back to you. 

Aug 19, 2016 12:26

That didn't help at all. I still have to publish the page manually in the cms for the changes to be shown on the site.

Does it have anything to do with caching perhaps?

Aug 19, 2016 13:12

When you open the page in cms does it say it has pending changes to publish?

Aug 19, 2016 13:34

No, if I view the page in edit mode it has all the changes that I added in Inriver PIM but when I view it on the site it doesn't. It doesn't say that it needs to be published or anything...

Aug 19, 2016 13:36

Then a caching problem is very possible. If the cms publish kills the cache as it should but your PageStoreService does not.

I am afraid you will have to check the remote event configuration, is the cms site and your job listening/posting to the same events?

Aug 19, 2016 13:46
Aug 19, 2016 14:02

I will try and get back to you.

Aug 19, 2016 14:14

I can't find that class and method through the PageStoreService

Aug 19, 2016 14:56

Sorry, did not realize you were using the PageStoreService

Aug 19, 2016 14:58

I will add the a class that inherits the interface IInitializabaleModule and then add functionality for what happens when a page that is of a specific type is published. I will call the RemovePage-method you wrote about above. 

Aug 19, 2016 15:03

I solved this one. Support could'nt tell me if there was a method in the PageStoreService similiar to CreateWritableClone.

So, I left this line in my connector:

epi.Save(languageBranch, SaveAction.ForceCurrentVersion, AccessLevel.NoAccess);

And in my epi-project I added a class that inherits the IInitializableModule. I then added the ContentEvent for SavedContent and implemented the method as below:

        private void contentEvents_SavedContent(object sender, EPiServer.ContentEventArgs e)


            if (e != null && e.ContentLink != null)


                var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();



                    var page = contentRepository.Get<PageData>(e.ContentLink);

                    if (!PageEditing.PageIsInEditMode && (page is RangePageType

                        || page is CollectionsPageType

                        || page is ProductFloorPageType))





                catch (Exception ex)


                    //what to do, what to do...




This works just fine so far! Let me know if you come up with a better solution.

Thank you everyone who answered my post! :)

Aug 29, 2016 10:21
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.