Magnus Rahl
Feb 18, 2009
  7018
(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
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024