Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Magnus Rahl
Feb 18, 2009
  6909
(0 votes)

Migrating PersonalizedData – the quick and dirty way

If the site you are migrating is using the PersonalizedData class to store non-standard values for the users, you will soon discover that the Migration Tool does not (yet?) migrate this data. You have to do it yourself, and here is a quick and dirty way to do it.

Description

Linked from this post are two aspx pages.ExportUserProfileDataFromEPiServer4.aspx will export data from PersonalizedData objects on the CMS 4.62 site and store it in an XML file. ImportUserProfileDataToEPiServer5.aspx will import the data to the EPiServerProfile objects on the CMS 5 site.

Edit the files to include the properties you need and to use a file path where the webserver user has sufficient access rights.

Example for ExportUserProfileDataFromEPiServer4.aspx:

   1: private Dictionary<string, string> GetDataForProfile(PersonalizedData data)
   2:     {
   3:         Dictionary<string, string> values = new Dictionary<string, string>();
   4:         //
   5:         // TODO: Add code here to export values
   6:         //
   7:         // Example:
   8:         // // "MyKey" will be the key to find the value when importing
   9:         // values.Add("MyKey", data.Description);
  10:  
  11:         values.Add("Description", data.Description);
  12:         values.Add("NewsletterSubscriptions", data["NewsletterSubscriptions"] as string);
  13:  
  14:         return values;
  15:     }
  16:  
  17:     private string FilePath
  18:     {
  19:         get
  20:         {
  21:             //
  22:             // TODO: Set output filename here
  23:             //
  24:             string filePath = @"C:\Temp\UserData\UserData.xml";
  25:             return filePath;
  26:         }
  27:     }

Example for ImportUserProfileDataToEPiServer5.aspx:

   1: private void SetDataForProfile(EPiServerProfile profile, Dictionary<string, string> data)
   2: {
   3:     //
   4:     // TODO: Add code here to import values
   5:     //
   6:     // Example: 
   7:     // // "Key" is the string used to store the value when exported
   8:     // string value = data["Key"];
   9:     //
  10:     // // Add logic to import the value
  11:     // if (!String.IsNullOrEmpty(value))
  12:     // {
  13:     //     profile["ProfileProperty"] = value;
  14:     // }
  15:     string desc = data["Description"];
  16:     if (!String.IsNullOrEmpty(desc))
  17:     {
  18:         profile["NewsLetterDescription"] = desc;
  19:     }
  20:  
  21:     string sub = data["NewsletterSubscriptions"];
  22:     if (!String.IsNullOrEmpty(sub))
  23:     {
  24:         profile["NewsletterSubscriptions"] = sub;
  25:     }
  26: }
  27:  
  28: private string FilePath
  29: {
  30:     get
  31:     {
  32:         //
  33:         // TODO: Set input filename here
  34:         //
  35:         string filePath = @"C:\Temp\UserData\UserData.xml";
  36:         return filePath;
  37:     }
  38: }

You also have to add your new properties to the profile/properties section of the CMS 5 site web.config, if you haven’t already done so.

Then just put the files somewhere in your sites, navigate to ExportUserProfileDataFromEPiServer4.aspx and run the export and then navigate to ImportUserProfileDataToEPiServer5.aspx and run the import. Done!

Download

Download MigratePersonalizedData.zip here.

Feb 18, 2009

Comments

Sep 21, 2010 10:32 AM

Excellent, Magnus. Thanks for the heads-up.
/ Mårten Berg

Magnus Rahl
Magnus Rahl Sep 21, 2010 10:32 AM

Apparently the latest version of the migration tool can handle this conversion, it is even possible to hook event handlers in to process the information before it is written to the personalization provider.

Please login to comment.
Latest blogs
Stop Managing Humans in Your CMS

Too many times, a content management system becomes a people management system. Meaning, an organization uses the CMS to manage all the information...

Deane Barker | Nov 30, 2023

A day in the life of an Optimizely Developer - Optimizely CMS 12: The advantages and considerations when exploring an upgrade

GRAHAM CARR - LEAD .NET DEVELOPER, 28 Nov 2023 In 2022, Optimizely released CMS 12 as part of its ongoing evolution of the platform to help provide...

Graham Carr | Nov 28, 2023

A day in the life of an Optimizely Developer - OptiUKNorth Meetup January 2024

It's time for another UK North Optimizely meet up! After the success of the last one, Ibrar Hussain (26) and Paul Gruffydd (Kin + Carta) will be...

Graham Carr | Nov 28, 2023

Publish content to Optimizely CMS using a custom GPT from OpenAI 🤖

Do you find the traditional editor interface complicated and cluttered? Would you like an editorial AI assistant you can chat with? You can!

Tomas Hensrud Gulla | Nov 28, 2023 | Syndicated blog