Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Magnus Rahl
Feb 18, 2009
  6984
(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
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog