locked
Is it possible to import user quick links? RRS feed

  • Question

  • I am migrating from a custom developed ASP.NET intranet to SharePoint 2010.  The previous developer had created quick links functionality in the ASP.NET site, which are stored per user in a SQL table.  So I do have the user's domain account, the url and site description as columns in a table.  This is HEAVILY used functionality and I know my users are going to freak out if they lose their existing quick links when I move the intranet to SharePoint. 

    I see that Quick Links are maintained per user at this URL in SP2010: http://server/_layouts/MyQuickLinks.aspx

    Is there a way to import the quick links from this external SQL table into SharePoint 2010?  I can add the URL above as a link on the profile page and they would then have access to their links...even if it's a few extra hops.

    Wednesday, January 16, 2013 4:23 PM

Answers

  • Dasani2008

    You will need to write custom code and you would need to use QuickLinkManager Class to create quick links.

    http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.quicklinkmanager.aspx

    Here is how I envision this. (Some code is copied from the link above)

    public void QuickLinkSample()
            {
                SPSite site = new SPSite("SITEURL");
                SPServiceContext serviceContext = SPServiceContext.GetContext(site);
    
    
                UserProfileManager upm = new UserProfileManager(serviceContext);
    
                // This is just an example but basically you will be looping through your Users and passing their Username.
                string strUser = "DOMAIN\\USERNAME";
                if (upm.UserExists(strUser))
                {
    
                    UserProfile u = upm.GetUserProfile(strUser);
                    QuickLinkManager qlm = u.QuickLinks;
    
    // I have hard coded the link but you will be reading these from your SQL DB.
    
                    string strTitle = "mylink";
                    string sLinkUrl = "http://my";
                    string strGroup = "my group";
                    QuickLink ql = qlm.Create(strTitle, sLinkUrl, QuickLinkGroupType.UserSpecified, strGroup, Privacy.Public);
    
                    ql.Commit();
    
    
                }
            }


    To run the code above you will need reference to Microsoft.Office.Server.UserProfiles (in Microsoft.Office.Server.UserProfiles.dll)

    Edit: You can change privacy of these links based on your requirement.


    Amit



    • Edited by Amit V Wednesday, January 16, 2013 6:49 PM
    • Marked as answer by Dasani2008 Wednesday, January 16, 2013 7:30 PM
    Wednesday, January 16, 2013 6:40 PM

All replies

  • If you just want to maintain them as a links list, then export from SQLS to Excel, then import to SharePoint.

    Steve Clark, MCTS | Twin-Soft.com
    Easy Bins Roll-off Dumpster Rentals of Northern VA. Specializing in driveway-sized roll-off dumpsters in Alexandria, Annandale, Arlington, Fairfax, and Springfield.

    Wednesday, January 16, 2013 6:21 PM
  • I beleive you want to show user based quick lilnks....if that is the case....

    Yes, It is possible. There are many ways to achive this...

    Please follow the logical steps below,

    1. Create a Custom list say "Quick Links" your SharePoint site.

    2. Configure Item level permissions as follows,

    List Settings -->Advanced settings

    Item-level Permissions

    Specify which items users can read and edit.

    Note: Users with the Manage Lists permission can read and edit all items. Learn about managing permission settings.
    Read access:   Specify which items users are allowed to read
    Read items that were created by the user (Select this )
    Create and Edit access:   Specify which items users are allowed to create and edit
    Create items and edit items that were created by the user (select this)

    3. Write a .Net program to migrate your user based quick links from SQL to SharePoint "Quick Links" list.

    (You can Migrate the data using Client Object Model (or) Server Object Model.  )

    4.  While migrated the data, ensure to set the Created & Modified fields with the appropriate users.

    ----------------------------------------------------------------
    If my post is helpful, please vote!
    If you think my solution worked for you, please mark as Answer!
    Thanks.


    • Edited by ParthaStarSP Wednesday, January 16, 2013 7:03 PM Modified the html code
    Wednesday, January 16, 2013 6:33 PM
  • Dasani2008

    You will need to write custom code and you would need to use QuickLinkManager Class to create quick links.

    http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.quicklinkmanager.aspx

    Here is how I envision this. (Some code is copied from the link above)

    public void QuickLinkSample()
            {
                SPSite site = new SPSite("SITEURL");
                SPServiceContext serviceContext = SPServiceContext.GetContext(site);
    
    
                UserProfileManager upm = new UserProfileManager(serviceContext);
    
                // This is just an example but basically you will be looping through your Users and passing their Username.
                string strUser = "DOMAIN\\USERNAME";
                if (upm.UserExists(strUser))
                {
    
                    UserProfile u = upm.GetUserProfile(strUser);
                    QuickLinkManager qlm = u.QuickLinks;
    
    // I have hard coded the link but you will be reading these from your SQL DB.
    
                    string strTitle = "mylink";
                    string sLinkUrl = "http://my";
                    string strGroup = "my group";
                    QuickLink ql = qlm.Create(strTitle, sLinkUrl, QuickLinkGroupType.UserSpecified, strGroup, Privacy.Public);
    
                    ql.Commit();
    
    
                }
            }


    To run the code above you will need reference to Microsoft.Office.Server.UserProfiles (in Microsoft.Office.Server.UserProfiles.dll)

    Edit: You can change privacy of these links based on your requirement.


    Amit



    • Edited by Amit V Wednesday, January 16, 2013 6:49 PM
    • Marked as answer by Dasani2008 Wednesday, January 16, 2013 7:30 PM
    Wednesday, January 16, 2013 6:40 PM
  • Amazing how many different ways folks can think up!  I guess that's a good thing. Amit is correct in that I want to manage it across the farm, not in a single list. 

    I actually figured out another way that is similar to Amit's but with less code... using the AddLink method of the UserProfileService.asmx web service.  It basically does exactly what Amit is doing.  The only reason I prefer that method is that this is a one time import of QuickLinks from an external SQL source, so my code will be running in a .NET app outside of SharePoint.

    Thanks everyone for the assistance.

    Wednesday, January 16, 2013 7:32 PM