Tridion Core Service Update Error - continued

In the refactoring exercise we are working on, we need to change the Page Templates for selected websites. Most pages get localized and update their page templates with the code below, but for some we get the following error:

"Name, file name must be unique for elements of the type: Page within its Structural group and its Blueprint context. Source or sources of conflict tcm: 121: 3456-64."

I checked both the current page being processed and the page indicated in the error, and both have unique names and file names. Any ideas that might be causing the problem?

PS I was able to solve an earlier error with wonderful suggestions sent to my question. Expect a similar answer this time.

try { pData = client.Read(page.Attribute("ID").Value, null) as PageData; //Localize Page if (!(bool)pData.BluePrintInfo.IsLocalized) { client.Localize(pData.Id, new ReadOptions()); if (dTemplateIDs.ContainsKey(pData.PageTemplate.IdRef.ToString())) { pData.IsPageTemplateInherited = false; pData.PageTemplate.IdRef = dTemplateIDs[pData.PageTemplate.IdRef]; client.Update(pData, new ReadOptions()); } } } catch (Exception ex) { Console.WriteLine("Error Inner " + ex.Message); } 
+4
source share
1 answer

There are some errors in your code, but you are not sure if they throw an exception, but it’s still worth fixing. First of all, you really do not read the page, since your ReadOptions null when you read it. Secondly, you should get your page from the Localize method, and then update the localized version of the page. Like this:

 try { // You need read options here pData = (PageData) client.Read(page.Attribute("ID").Value, new ReadOptions()); //Localize Page if (!(bool)pData.BluePrintInfo.IsLocalized) { // Get localized page here pData = (PageData) client.Localize(pData.Id, new ReadOptions()); if (dTemplateIDs.ContainsKey(pData.PageTemplate.IdRef.ToString())) { pData.IsPageTemplateInherited = false; pData.PageTemplate.IdRef = dTemplateIDs[pData.PageTemplate.IdRef]; // You do not need read options here client.Update(pData, null); } } } catch (Exception ex) { Console.WriteLine("Error Inner " + ex.Message); } 

And finally, if all this does not help, can you also send a stack trace?

+4
source

All Articles