SharePoint Blog - René Hézser

Anmelden  RSS Feed RSS Feed
Startet die Suche

Nov 172007

HowTo Create a contact form

A contact form is a must have on all websites. You can realize such a form with build in functionality, even if you have anonymous "logins" on your SharePoint site.

Steps to create a contact form:

  • Create a custom list, and configure it with all the fields you need.
  • Change the security settings in the advanced settings for the new contact list

Now everything is set up for your contact form. But how do you get knowledge of a new item in your list? You can not configure an alert, because you are only allowed to view your own posts. But you can add the RSS feed for the list into your Outlook to be notified if someone tries to contact you.


Published: 11/17/2007  3:09 PM | 3  Comments | 0  Links to this post
Tagged as: SharePoint

Nov 172007
Nov 172007

SharePointConsole

I wrote a Console application, which will allow you do some common tasks for your SharePoint environment. stsadm lacks some functionality like recyling all list items from a list...

Just copy the exe to your SharePoint Server, and execute it with an account which has the appropriate rights on your farm.

Usage:
SharePointConsole http://siteurl[/weburl] Command [Parameter1 Parameter2]

The SharePointConsole has the following parameters:

  • EnumContentTypes
  • CreateContentType
  • RenameContentType
  • DeleteContentType
  • DeleteAllListItems
  • ShowInNewForm
  • ShowInEditForm
  • ShowInDisplayForm
  • DeleteAllVersions
  • RecycleAllVersions
  • SetTitleWithFilename
  • SetSearchCenterUrl
  • SystemUpdate
  • FeatureManager
  • EmptyRecycleBin

EnumContentType:
Returns all content types from the specified sitecollection.

CreateContentType newName [Parent ContentType]:
Creates a new content type and inherrits from an exiting one, if a parent content type is specified.

RenameContentType contentType newName:
Renames a content type

DeleteContentType Name:
Deletes a content type

DeleteAllListItems ListName:
Deletes all listItems from the specified list (use the displayname)

RecycleAllListItems ListName:
Recycles (moves to Recycle Bin) all listItems from the specified list (use the d
isplayname)

ShowInNewForm ListName FieldName bool:
Changes the visibility of a field in the NewForm

ShowInEditForm ListName FieldName bool:
Changes the visibility of a field in the EditForm

ShowInDisplayForm ListName FieldName bool:
Changes the visibility of a field in the DisplayForm

DeleteAllVersions ListName:
Deletes all version except the current one

RecycleAllVersions ListName:
Recycles all version except the current one

SetTitleWithFilename ListName:
Sets the Title of all Documents with its filename without extension

SetSearchCenterUrl SearchCenterUrl:
Sets the SearchCenterUrl for an entire WebApplication

SystemUpdate ListName SleepTime itemID:
Hit each ListItem and do a SystemUpdate(false) to call attached EventHandlers. With SleepTime you define how many seconds to wait, before working on the next ListItem. If the itemID is != 0, only that item will be updated

FeatureManager featureID Enable/Disable [AllSites|AllWebs|Farm] :
Enable or Disable a feature by its ID. The optional paramter AllSites enables the feature on all sitecollections AND webs, AllWebs only in all webs of the sitecollection and Farm in the whole farm

EmptyRecycleBin
Empties the Recylce Bin for the site collection (from all stages and all webs!)

Update 28. May 2009
New commands added.

Download Download the SharePointConsole


Published: 11/17/2007  11:53 AM | 5  Comments | 0  Links to this post
Tagged as: Development, SharePoint

Nov 152007

HowTo create an object if you only have its type as string

Sometimes you have only the type of an object, which you want to create. Meaning you want to create an object dynamically. This is how you would achieve your goal:

In my case I wanted to create a SPField from its typename.

   1:  string typename = "Microsoft.SharePoint.SPFieldText, Microsoft.SharePoint, "+
   2:      "Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c";
   3:  Type t = Type.GetType(typename, true, true);
   4:  object newObject = System.Activator.CreateInstance(t, 
   5:      BindingFlags.SetProperty, new object[] { fields, "Title" });

I know one constructor for a SPField is to create a new object with the SPFieldCollection and its name. The problem was that the constructor could be found.

You can view all available constructors with:

   1:  ConstructorInfo[] constructors = t.BaseType.GetConstructors();

After looking back into the SDK, I noticed that SharePoint can be so easy. You can create a SPField like this:

   1:  SPField newField = new SPField(fields, "SPFieldText", "new Field Name");

Next time I will remember :-)

Keywords: Create SPField from typename, Erstellen eines spfield von seinem typ namen


Published: 11/15/2007  4:19 PM | 0  Comments | 0  Links to this post
Tagged as: Development, SharePoint, SPField