Moving Subscriptions Between Users
description
Transcript of Moving Subscriptions Between Users
Moving Subscriptions Between Users
BY BRYAN · MAY 13, 2011
I was once on a project in 8.x days where one group of users were responsible for managing the subscriptions for larger sets. Most had anywhere between 10-20 subscriptions, and the largest were in the hundreds. This was back in the Narrowcast days where the subscriptions metadata was separate from the IServer metadata, and the connection was loose at best. When a person left or changed responsibilities, it was tedious to move their subscriptions without having to recreate them all. The best I could do was effectively transfer their entire account to the new person (along with some Narrowcast wizardry, this made it possible), though that’s not ideal for things like tracking statistics. Thankfully 9.0 introduced the integrated replacement for Web Subscriptions in the form of Distribution Services as well as Subscription Command Manager support. Today I’ll share a script to easily move all or select subscriptions between users.
This script must be run via Command Manager as a Procedure. To run it, simply go to File -> New Procedure and paste it in. You’ll need to set the three variables at the top, and also under the Test Information tab on the right hand side of Command Manager, you’ll need to connect to your IServer.
String sProjectName = “Project”; String oldUser = “User1″; String newUser = “User2″; ResultSet oSubs = executeCapture(“LIST ALL SUBSCRIPTIONS FOR OWNER ‘” + oldUser + “‘ FOR PROJECT ‘” + sProjectName + “‘;”); oSubs.moveFirst(); while (!oSubs.isEof() ) {
//get list of current subscriptions String sGUID = oSubs.getFieldValueString(DisplayPropertyEnum.GUID); //build the Alter statement String sQuery = “ALTER EMAILSUBSCRIPTION GUID ” + sGUID + ” OWNER “” + newUser + “” IN PROJECT “” + sProjectName + “”;”; //execute it printOut(sQuery);// execute(sQuery); oSubs.moveNext(); }Uncomment the execute() command when you’re ready to run it, or just view the printed commands that it’ll run and you can execute those manually.