Add Calendar Webpart to page

string filename = “SitePages/mypage.aspx”;

SPList list = web.Lists["Calendar"];


SPLimitedWebPartManager wpMgr = web.GetLimitedWebPartManager(filename,

System.Web.UI.WebControls.WebParts.


PersonalizationScope.Shared);

SPLimitedWebPartManager webPartManager = web.GetLimitedWebPartManager(filename,

System.Web.UI.WebControls.WebParts.


PersonalizationScope.Shared);

ListViewWebPart listViewWebPart = new
ListViewWebPart();

listViewWebPart.ListName = list.ID.ToString(“B”).ToUpper();

listViewWebPart.TitleUrl = list.DefaultViewUrl;

listViewWebPart.ViewType = ViewType.Calendar;

listViewWebPart.Title = “Kalender”;

listViewWebPart.ViewGuid = string.Empty;

 

webPartManager.AddWebPart(listViewWebPart, CommonConst.MiddleLeftZone, 0);

 

Categories: SharePoint2010, Webpart

TFS Build server Error permissions

“Failed to create directory ‘\\myshare\inetpub\wwwroot\mywebsite\mywebsite\mywebsite_20100610.3′.  User ‘NT AUTHORITY\NETWORK SERVICE’ needs write permissions to the path.”

To change the account, you’ll need to:

  1. Log in to the server hosting the Team Foundation Build service
  2. Start the Team Foundation Server Administration Console
  3. Select the ‘Build Configuration’ node in the left hand tree
  4. Find your build service at the top of the panel and select ‘Properties’ to configure it
  5. You’ll need to ‘Stop to make changes’ via the link in the popup window
  6. Finally in the ‘credentials’ section at the bottom change the radio button and put in the name and password for the account you wish to use.

I now have builds being pushed up successfully to our development server. 

To change the account, you’ll need to:

  1. Log in to the server hosting the Team Foundation Build service
  2. Start the Team Foundation Server Administration Console
  3. Select the ‘Build Configuration’ node in the left hand tree
  4. Find your build service at the top of the panel and select ‘Properties’ to configure it
  5. You’ll need to ‘Stop to make changes’ via the link in the popup window
  6. Finally in the ‘credentials’ section at the bottom change the radio button and put in the name and password for the account you wish to use.
Categories: Configuration, TFS 2010

User Profile Synchronization

Event Log:

The server encountered an unexpected error and stopped.
 
 ”ERR: MMS(1516): sql.cpp(5580): Query (CSession::Open()) performed with error
ERR: MMS(1516): sql.cpp(5601): Error retrieving error
BAIL: MMS(1516): sql.cpp(568): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): sql.cpp(384): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): sql.cpp(256): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): storeimp.cpp(272): 0×80230406 (An error has occurred at the store)
ERR: MMS(1516): server.cpp(294): Failed to connect to the database User Profile Service Application_SyncDB_25480d71476c456e861f8d660a1eb297 on TSTMSDB02
BAIL: MMS(1516): server.cpp(295): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): server.cpp(3518): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): service.cpp(1528): 0×80230406 (An error has occurred at the store)
ERR: MMS(1516): service.cpp(977): Error creating com objects. Error code: -2145188858. This is retry number 0.
ERR: MMS(1516): sql.cpp(5580): Query (CSession::Open()) performed with error
ERR: MMS(1516): sql.cpp(5601): Error retrieving error
BAIL: MMS(1516): sql.cpp(568): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): sql.cpp(384): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): sql.cpp(256): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): storeimp.cpp(272): 0×80230406 (An error has occurred at the store)
ERR: MMS(1516): server.cpp(294): Failed to connect to the database User Profile Service Application_SyncDB_25480d71476c456e861f8d660a1eb297 on TSTMSDB02
BAIL: MMS(1516): server.cpp(295): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): server.cpp(3518): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): service.cpp(1528): 0×80230406 (An error has occurred at the store)
ERR: MMS(1516): service.cpp(977): Error creating com objects. Error code: -2145188858. This is retry number 1.
ERR: MMS(1516): sql.cpp(5580): Query (CSession::Open()) performed with error
ERR: MMS(1516): sql.cpp(5601): Error retrieving error
BAIL: MMS(1516): sql.cpp(568): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): sql.cpp(384): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): sql.cpp(256): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): storeimp.cpp(272): 0×80230406 (An error has occurred at the store)
ERR: MMS(1516): server.cpp(294): Failed to connect to the database User Profile Service Application_SyncDB_25480d71476c456e861f8d660a1eb297 on TSTMSDB02
BAIL: MMS(1516): server.cpp(295): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): server.cpp(3518): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): service.cpp(1528): 0×80230406 (An error has occurred at the store)
ERR: MMS(1516): service.cpp(977): Error creating com objects. Error code: -2145188858. This is retry number 2.
ERR: MMS(1516): sql.cpp(5580): Query (CSession::Open()) performed with error
ERR: MMS(1516): sql.cpp(5601): Error retrieving error
BAIL: MMS(1516): sql.cpp(568): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): sql.cpp(384): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): sql.cpp(256): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): storeimp.cpp(272): 0×80230406 (An error has occurred at the store)
ERR: MMS(1516): server.cpp(294): Failed to connect to the database User Profile Service Application_SyncDB_25480d71476c456e861f8d660a1eb297 on TSTMSDB02
BAIL: MMS(1516): server.cpp(295): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): server.cpp(3518): 0×80230406 (An error has occurred at the store)
BAIL: MMS(1516): service.cpp(1528): 0×80230406 (An error has occurred at the store)
ERR: MMS(1516): service.cpp(977): Error creating com objects. Error code: -2145188858. This is retry number 3.
BAIL: MMS(1516): service.cpp(991): 0×80230406 (An error has occurred at the store)
Forefront Identity Manager 4.0.2450.11″

Solution:

Cumulative Update from 31. August 2010.

  1.  Install SharePoint Foundation 2010 hotfix   KB 2352346 and restart server
  2. Install SharePoint Server 2010 hotfix   KB 2352342 and restart server
  3. Delete and Config the User Profile Service again. 
Categories: Uncategorized

SharePoint 2010 Cumulative Update for August 31 2010

  •  SharePoint Foundation 2010 KB 2352346
  • SharePoint Server 2010 KB 2352342
  • SharePoint Server 2010 and Project Server 2010 KB 2352345

Click here

SharePoint Add\Get values from fields

When programming against SharePoint lists, it is difficult to retrieve or add value to a lookup field, hyperlink, Drop Down (choice) field. So I decided to share the experience with you :)

Add Value to Hyperlink (SPFieldUrlValue)

SPList oList = oWeb.Lists["YourListName"];

SPListItem newLink = oList.Items.Add();

SPFieldUrlValue oUrlValue = new
SPFieldUrlValue();

oUrlValue.Description = “Your link title”;

oUrlValue.Url = “http://www.YourLink.com/ “;

newLink["URL"] = oUrlValue;

newLink.Update();

 

Get Hyperlink values (SPFieldUrlValue)

SPList oList = oWeb.Lists["YourListName"];

SPListItem oListItem = oList.Items[0];

SPFieldUrlValue oUrlValue = new
SPFieldUrlValue(oListItem ["YourLinkItemFieldName"].ToString());

string linkTitle = oUrlValue.Description;

string linkURL = oUrlValue.Url;

 

Add value to LookupField (SPFieldLookupValue)

SPList oList = oWeb.Lists["YourListName"];

SPListItem oListItem = oList.Items.Add();

oListItem ["Title"] = “YorNewTitle”;

SPFieldLookupValue newValue = new
SPFieldLookupValue(14,“YourNewValue”);

oListItem ["LookupFieldName"] = newValue;

oListItem.Update();

 

Get Lookup value

SPList oList = oWeb.Lists["YourListName"];

SPListItem oListItem = list.Items[0];

SPFieldLookupValue LookupGroup = new
SPFieldLookupValue(oListItem["LookupFieldName"].ToString());

int lookedUpItemID = LookupGroup.LookupId;

string lookedUpItemTitle = LookupGroup.LookupValue;

 

Get People and group field value

SPList oList = oWeb.Lists["YourListName"];

SPListItem oListItem = list.Items[0];

SPFieldUser userField = (SPFieldUser) oListItem.Fields.GetField(“AssignedTo”);

SPFieldUserValue fieldValue = (SPFieldUserValue) userField.GetFieldValue(oListItem ["AssignedTo "].ToString());

SPUser _user = fieldValue.User;

string _logingName = _ user.LoginName.ToString();

 

Categories: Uncategorized

SharePoint 2010 – SiteColumn and ContentType in VS2010

  1. Create a SharePoint Empty project in Visual Studio 2010
  2. Righ click on project folder in VS 2010 and Add -> New Item…
  3. Sellect Content Type

    Click Add.
  4. Type in the ContentTypes\Elements.xml

Elements.xml

<?xml
version=1.0
encoding=utf-8?>

<Elements
xmlns=http://schemas.microsoft.com/sharepoint/>

 Site Columns

<!– Site Columns: –>
<Field
ID={41937D9C-27E0-4180-93A7-57E2A40B3714}
Group=MyColumns
Name=SiteName
DisplayName=SiteTitle
Type=Text />

<Field
ID={44EE672F-A5E6-428F-A3C2-A40F65E8AAE5}
Group=MyColumns
Name=SiteUrl
DisplayName=SiteUrl
Type=URL
Format=Hyperlink />

<Field
ID={B76DFB77-A8AB-4A7B-81C6-CAF9AFE919FB}
Group=MyColumns
Name=SiteResponsible
DisplayName=Responsible
Type=User
UserSelectionMode=PeopleOnly
ShowField=Name
Presence=TRUE />

<Field
ID={F62B867A-BAA1-4953-B59F-4AF2C4A61029}
Group=MyColumns
Name=SiteContactPerson
DisplayName=ContactPerson
Type=User
UserSelectionMode=PeopleOnly
ShowField=Name
Presence=TRUE />

<!– Site Lookup Columns: –>
<Field
ID={4C259E34-19D2-4174-BBCF-6C719CA561A3}
Group=MyColumns
Name=SiteTemplateType
DisplayName=Templates
StaticName=SiteTemplateType
Type=Lookup
List=Lists/SiteTemplate
ShowField=Title
Hidden=FALSE
Required=FALSE
Sealed=TRUE
Overwrite=TRUE />

 <!– Site Lookup Columns: –>
<Field
ID={77147EAB-7AFB-4200-A221-A3D1928A6C94}
Group=MyColumns
Name=Unit
DisplayName=Unit
Type=Choice
Format=Dropdown
Required=TRUE>

<CHOICES>

<CHOICE>Unit 01</CHOICE>

<CHOICE>Unit 02</CHOICE>

<CHOICE>Unit 03</CHOICE>

<CHOICE>Unit 04</CHOICE>

</CHOICES>

</Field>

 ContentType

<!– Parent ContentType: SiteInfo based on Item (0×01) –>

<ContentType
ID=0x0100caf4177b1b994e9f9f60e356b230157e
Name= SiteInfoProvisioning
Group=MyColumns
Description= SiteInfoProvisioning.
Inherits=TRUE
Version=0>

<FieldRefs>
<FieldRef
ID={41937D9C-27E0-4180-93A7-57E2A40B3714}
Name= SiteName
DisplayName=SiteTitle
ShowInDisplayForm=TRUE
ShowInNewForm=FALSE />

<FieldRef
ID={44EE672F-A5E6-428F-A3C2-A40F65E8AAE5}
Name=SiteUrl
DisplayName=SiteUrl
ShowInDisplayForm=TRUE
ShowInNewForm=FALSE />

<FieldRef
ID={B76DFB77-A8AB-4A7B-81C6-CAF9AFE919FB}
Name=SiteResponsible
DisplayName=Responsible/>

<FieldRef
ID={F62B867A-BAA1-4953-B59F-4AF2C4A61029}
Name=SiteContactPerson
DisplayName=Contactperson />
<FieldRef
ID={E89241A4-5302-4B3E-92D2-4B7C23427C9A}
Name=SiteTemplateType
DisplayName=Templates />
<FieldRef
ID={77147EAB-7AFB-4200-A221-A3D1928A6C94}
Name=Lifetime
DisplayName=Lifetime
Required=TRUE />
</FieldRefs>
</ContentType>

Now you have created Site Columns and Site ContentType.

The ContentType and SiteColumns are ready to deployment to SharePoint Farms.

Categories: Uncategorized

SharePoint 2010 – Hands on Lab

Microsoft has posted some good basic explanation and samples for SharePoint development.

Click here

SharePoint 2010 Search Service Application – Configuration

 

How to configure the Search service in SharePoint 2010?


1. Go to Central Administration
2. Select Manage Services Applications under the Application Management Menu.


3. Here is a list of all service applications. Click New and select Search Service Application.


4. Please enter the name of the Application Service and account information.


5. Click OK to complete configuration.
6 Here is an overview of Index and crawl and database contents.

SharePoint 2010/2007 Custom Site Column – Field Type and Options

Type (as shown on the Create Column page)

Field Type

Notes

MSDN Links

Single line of text

Type=”Text”

   

Microsoft.Sharepoint.SPFieldText

Multiple lines of text

Type=”Note”

In the Create Column page, can pick the type of text to allow. To enable the different sub-types, you need to set a couple of other attributes on the field element.

Plain Text
RichText=”FALSE”  (default value)

Rich Text
RichText=”TRUE”
RichTextMode=”Compatible”  (default value)

Enhanced Text
RichText=”TRUE”
RichTextMode=”FullHtml”

In addition, you can also set the number of lines to display using the NumLine attribute.

Further Information on MSDN:

Microsoft.Sharepoint.SPFieldMultiLineText

Choice (menu to choose from)

Single Choice
Type=”Choice”

Multi-Choice
Type=”MultiChoice”

Pick the display format for the Choice and Multi-Choice types, respectively:

Drop-Down Menu or Combo Box
Format=”Dropdowns”

Radio Buttons or Check Boxes
Format=”RadioButtons”

Define the options a user can pick from using the Choices element. Below is a skeleton to explain this.

<Field Name=”MyOptions” Type=……>
  <CHOICES>
     <CHOICE>Option 1</CHOICE>
     <CHOICE>Option 2</CHOICE>
  </CHOICES>
</Field>

If you would like to give the user an option to add their own value, set the attribute FillInChoice=”TRUE”.

Microsoft.Sharepoint.SPFieldChoice
Microsoft.Sharepoint.SPFieldMultiChoice

Number

Type=”Integer”

This field type also lets you define:

Minimum Value (0 for example)
Min=”0″

Maximum Value (100 for example)
Max=”100″

Decimal Places (Default is Automatic, example 2 decimal places)
Decimals=”2″

Show as Percentage (Default is False)
Percentage=”FALSE”

Microsoft.SharePoint.SPFieldNumber

Currency

Type=”Currency”

This field type also lets you define:

Minimum Value (0 for example)
Min=”0″

Maximum Value (100 for example)
Max=”100″

Decimal Places (Default is Automatic, example 2 decimal places)
Decimals=”2″

Currency Format
This sets the display format of the currency.

LCID=”3081″

3081 sets the format English – Australian. For a complete list of Locales, see the MSDN link in the next column.

Microsoft.Sharepoint.SPFieldCurrency

Locale IDs

Date and Time

Type=”DateTime”

This field also lets you define:

Date and Time Format
Show the date only:
Format=”DateOnly”

Show the date and time:
Format=”DateTime”

Microsoft.Sharepoint.SPFieldDateTime

Yes/No

Type=”Boolean”

When setting the default value, you need to use the binary values:

No/False = 0
Yes/True = 1

Microsoft.Sharepoint.SPFieldBoolean

Person or Group

Single User or Group
Type=”User”

Multiple Users or Groups
Type=”MultiUser”

This field also lets you define:

Allow multiple selections
Set the Type to MultUser and the attribute Mult=”TRUE”

Allow selection of
People Only
UserSelectionMode=”PeopleOnly”

People and Groups
UserSelectionMode=”PeopleAndGroups”

Choose from
If you want to limit the option list to a SharePoint Group, use the UserSelectionScope attribute. Set it to the ID of the SharePoint group (Integer value). For example, UserSelectionScope=”3″.

Show field
Set the name of the field from the User’s profile properties that you want to display. For example, show the user’s name property:
ShowField=”Name”

If you would also like to show presence (Office Communicator integration required):
Presence=”TRUE”

Microsoft.Sharepoint.SPFieldUser

Hyperlink or Picture

Type=”URL”

You can display the URL as a Hyperlink or Picture. Use the Format attribute to pick which one:

Hyperlink
Format=”Hyperlink”

Picture
Format=”Image”

Microsoft.Sharepoint.SPFieldUrl

 
 

Follow

Get every new post delivered to your Inbox.