Replicate "You can create a new culture version of the page by copying content from another language

Sylvain C. asked on November 19, 2021 15:55

Hello,

Using Xperience 13.0.48, I am trying to replicate "the creation of new culture version of an existing by copying the page" In the situation, my initial page in English contains an attachment in a "File" field. It works fine in the admin UI, I retrieve the same attachment in both versions (English & Spanish).

But when I try to do the same by using the API:

TreeNode page = tree.SelectNodes()
    .Path("/Articles/Coffee-Beverages-Explained")
    .OnCurrentSite()
    .Culture("en-US")
    .TopN(1)
    .FirstOrDefault();

if (page != null)
{
    page.InsertAsNewCultureVersion("es-ES");
}

The culture version in Spanish of my page is correctly created, with all fields being copied except that my attachment in my File field is empty... What did I miss?

Thank you

Sylvain

Correct Answer

Sylvain C. answered on November 19, 2021 19:38

Ok, I was able to make it work by changing parameters of NewCultureDocumentSettings:

DocumentHelper.InsertNewCultureVersion(new NewCultureDocumentSettings(ENDocPage,"es-ES")
                                {
                                    ClearAttachmentFields = false,                                                                   
                                    CopyAttachments = true                                    
                                });

Hope it would help someone.

Sylvain

1 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.