November Happy Hour will be moved to Thursday December 5th.

Magnus Rahl
Feb 18, 2009
  7088
(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
Optimizely SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Set Default Culture in Optimizely CMS 12

Take control over culture-specific operations like date and time formatting.

Tomas Hensrud Gulla | Nov 15, 2024 | Syndicated blog

I'm running Optimizely CMS on .NET 9!

It works 🎉

Tomas Hensrud Gulla | Nov 12, 2024 | Syndicated blog

Recraft's image generation with AI-Assistant for Optimizely

Recraft V3 model is outperforming all other models in the image generation space and we are happy to share: Recraft's new model is now available fo...

Luc Gosso (MVP) | Nov 8, 2024 | Syndicated blog