# Friday, January 29, 2010

Required using statements

using Microsoft.SharePoint;
using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;

Then sample code

try
{
   site = SPContext.Current.Site;
   ServerContext serverContext = ServerContext.GetContext(site);
   UserProfileManager userProfileManager = new UserProfileManager(serverContext);
   UserProfile currentUserUserProfile = userProfileManager.GetUserProfile(System.Web.HttpContext.Current.User.Identity.Name);

   string nameSurname = (string)currentUserUserProfile["preferredname"].Value;
   string email = (string)currentUserUserProfile["workemail"].Value;
   string companyName = (string)currentUserUserProfile["company"].Value;
}
finally
{
   site.RootWeb.Dispose();
   site.Dispose();
}
posted on Friday, January 29, 2010 1:13:28 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback

Atalay Aktaş works on Microsoft Turkey Office as Business Productivity Solutions Specialist. He shares a presentation that contains general information about Sharepoint and Office 2010 product family. Presentation language is Turkish, includes 50 slide and totaly 14.8 MB on SkyDrive.

You can download it via this link

posted on Friday, January 29, 2010 12:12:21 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback
# Thursday, January 28, 2010
SPFieldLookupValue category = new SPFieldLookupValue(1, "Books");

and then use it to set field value

item["Category"] = category
posted on Thursday, January 28, 2010 12:11:57 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback
        static void Main(string[] args)
        {
            SPSite site = null;
            SPWeb web = null;

            try
            {
                site = new SPSite("http://testSite/SubWeb/Pages/");
                web = site.OpenWeb();
                PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
                SPContentTypeId contentType = new SPContentTypeId("YourContentTypeId");
                PageLayout[] layouts = publishingWeb.GetAvailablePageLayouts(contentType);
                PageLayout pageLayout = layouts[0];
                string pageName = Guid.NewGuid().ToString() + ".aspx";

                SPUser user = web.EnsureUser("DOMAIN\\USERNAME");
                string createdDate = "2009-11-05T22:35:10Z";
                string modifiedDate = "2009-11-05T22:35:10Z";

                web.AllowUnsafeUpdates = true;
                PublishingPage newPage = publishingWeb.GetPublishingPages().Add(pageName, pageLayout);

                newPage.ListItem["Author"] = user.ID;
                newPage.ListItem["Editor"] = user.ID;
                newPage.ListItem["Created"] = createdDate;
                newPage.ListItem["Modified"] = modifiedDate;
                newPage.ListItem.UpdateOverwriteVersion();

                web.AllowUnsafeUpdates = false;

                Console.WriteLine("OK");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadLine();
            }
            finally
            {
                web.Dispose();
                site.RootWeb.Dispose();
                site.Dispose();
            }
        }
posted on Thursday, January 28, 2010 12:06:33 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback
        static void Main(string[] args)
        {
            SPSite site = null;
            SPWeb web = null;

            try
            {
                site = new SPSite("http://testsite/subweb/Pages/");
                web = site.OpenWeb();
                PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
                SPContentTypeId contentType = new SPContentTypeId("YourContentTypeID");
                PageLayout[] layouts = publishingWeb.GetAvailablePageLayouts(contentType);
                PageLayout pageLayout = layouts[0];
                string pageName = "PageName.aspx";

                PublishingPage newPage = publishingWeb.GetPublishingPages().Add(pageName, pageLayout);
                newPage.Update();
                newPage.ListItem.File.CheckIn("created");
                newPage.ListItem.File.Publish("created");

                Console.WriteLine(newPage.Url);
                Console.WriteLine("OK");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadLine();
            }
            finally
            {
                web.Dispose();
                site.RootWeb.Dispose();
                site.Dispose();
            }
        }
posted on Thursday, January 28, 2010 8:39:37 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback

Consider the following scenario. You create a survey, and then you add a workflow to the survey in Microsoft Windows SharePoint Services 3.0. Then, you connect to the survey and respond to it. Finally, you view the response that you submitted, and then you try to start a workflow from the response. To do this, you click the arrow next to the response, click Workflows, click the workflow that you added, type your user name in the Reviewers box, and then click Start. However, the workflow does not start. Instead, the status of the workflow appears as Failed to Start.

This issue occurs because starting a workflow from a survey response is not supported in Windows SharePoint Services 3.0. Although the Workflows option appears when you click the arrow next to a survey response, you cannot start a workflow from a survey response.

posted on Thursday, January 28, 2010 8:21:45 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback
# Tuesday, January 26, 2010

Microsoft recently released a new Silverlight 4 based facebook client for both Windows and Mac OS X. Scott Guthrie originally demonstrated this Silverlight client for Facebook during his PDC 2009 keynote late last year.

For more information, visit MicrosoftFeed article.

posted on Tuesday, January 26, 2010 8:32:11 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback
# Monday, January 25, 2010

The Save (Not Permitted) dialog box warns you that saving changes is not permitted because the changes you have made require the listed tables to be dropped and re-created.

The following actions might require a table to be re-created:

  • Adding a new column to the middle of the table
  • Dropping a column
  • Changing column nullability
  • Changing the order of the columns
  • Changing the data type of a column

To change this option, on the Tools menu, click Options, expand Designers, and then click Table and Database Designers. Select or clear thePrevent saving changes that require the table to be re-created check box.

posted on Monday, January 25, 2010 8:39:46 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback
# Friday, January 15, 2010

Based on customer requests for more robust compliance features, Microsoft has improved the validation capabilities of lists and libraries. Validation is now supported at both list and item levels.

For instance, a list owner can configure a validation to disallow the start date of an event item (stored in one column) to be after the end date of the event (stored in another column). If a user enters a start date that is later than the specified end date they will be presented with an error message when he or she attempts to save the item.

In another example, people can specify a column in a list as unique so that a contact list may not contain two entries with the same email address.

posted on Friday, January 15, 2010 9:02:35 AM (GMT Standard Time, UTC+00:00)  #    Comments [6] Trackback

The activity feed in SharePoint 2010 is very interesting. It is a way to see and read what your co-workers are doing. Most of your actions in SP2010 will end up in the activity feed.

But what about your actions and updates outside the organisation? Like twitter?

Stef van Hooijdonk created a class that will import your twitter updates ( through your public timeline rss feed ) and will post those updates to your activityfeed. Form more information and download; click here...

 

posted on Friday, January 15, 2010 7:35:00 AM (GMT Standard Time, UTC+00:00)  #    Comments [1] Trackback