User Migration From EPiServer 4.x to CMS5(R2)

The new version of EPiServers migration tool is supposed to support user personalization migration to the new enviroment. The good news is that it does migrate all users and generates a new password. The bad news is that it forgets which pages they subscribed too and the interval.

On this project, we also use SubscriptionCategories which basicly sends a newsletter everytime a page is created under that category which of course didn’t get migrated to the new enviroment.

What you need to know is open up a connection to the old database and fill up a datatable with info from tblUserProperty, tblSID and tblUser. You need to bring up the username, email (we use the email as username for all subscribers), interval, categories and which pages they subscribe too. I had to make three different queries to bring up what I needed though, one for the categories, one for the interval and one for the pages. I’m sure that an SQL genius can make it in one call.

Once you’ve filled up your datatable, bind it to a repeater and just print it all out. Might be nice to see it work before you do a full migration atempt. Once in the repeater, I call for the method I made to update the subscription information.

[sourcecode language=’csharp’]
private void UpdateUserSubscription(string user, int page, string categories)
{
EPiServerProfile profile = EPiServerProfile.Get(user);
profile[”SubscribeCategories”] = categories;
profile.SubscriptionInfo.Interval = CheckUserInterval(user);
profile.SubscriptionInfo.SubscribeTo(new PageReference(page));
profile.Save();
}

[/sourcecode]

Basicly, you need to load up the profile you wish to alter and then fill it up with whatever information you need. SubscribeCategories is the custom part of our subscription and the rest is interval and page to subscribe to. Just dont forget to save your profile, otherwise it wont save it to the database. The only time you don’t need to save the profile is if you’re altering the currentuser which is logged in. Then you can call on the methods you like and they will work without save. But when altering users that are not logged in, you’ll always need to save.

2 kommentarer

  1. Thanks for the information!
    It worked fine for me with one small ajustment:
    If you have a globalized site you also need to add which language the users shall subscribe to, otherwise the subscribers won’t get any mail at all. Write for example the following if you want the users to recive emails for updates och creation of swedish pages:
    profile.SubscriptionInfo.SubscribeTo(new PageReference(page),”sv”);

  2. Indeed. We had to add that to the subscriptions aswell in order to make it work. Kinda silly that they dont get a default language when being migrated 🙂

Lämna ett svar

Denna webbplats använder Akismet för att minska skräppost. Lär dig hur din kommentardata bearbetas.