Sunday, February 08, 2009

New MOSS internet site launched - good case study

One of the three Israeli mobile communication companies has released a new web site – using MOSS. From my initial review, it is one of the best implementations I have seen so far in that it:

  1. Works (I couldn’t find a page with errors or place holder text which is usual in new sites)
  2. works reasonably fast
  3. usable – nice big global navigation, in sub sites there is a nice distinct secondary navigation
  4. different sections have different backgrounds – so the shop pages look different from the customer relations pages
  5. makes use of personalisation – users can log on, see their account and special offers
  6. even search looks good and is optimised with keywords and best bets – although they could have used a different font for the description to make it different from the link)
  7. system pages are properly disabled – showing a user friendly error message
  8. same for page not found error
The site (which is in Hebrew) can be found under http://www.cellcom.co.il

Does anyone know who built the site for them? kudos!

Sunday, February 01, 2009

Dispose check tool - to check your best practices

Paul Andrew from Microsoft has just announced that the SPDisposeCheck tool was released to the public. I have tested this tool in Alpha and Beta, and provided Microsoft with feedback -and now the completed tool is ready for you to download. A must for every sharepoint developer! See Paul's blog post or go to the MSDN download page

Monday, January 26, 2009

Memberships

I was puzzled why on my development server the memberships web parts never showed the sites that my test users were members of. After much searching and tinkering I found that I needed to run a full profile import and a full search crawl. It could be that only one was required - but I cannot verify it. The profile import does say that it updates memberships, but even after that it didnt add the memberships - only after I performed a full search crawl that it started working.

Tuesday, January 06, 2009

Discounted Microsoft Certification code

Want to do a Microsoft certification exam? is it a Microsoft Certified Technology Specialist (MCTS), Microsoft Certified IT Professional (MCITP) and Microsoft Certified Professional Developer (MCPD) exam?

Here is how you can get 10% off the price, and get a free retake if you fail the first try. Simply go to http://www.learnandcertify.com/ and click on "Get my exam offer voucher" and when it asks you for the MVP promotion code, enter AUD2D426 and you will be sent a voucher to use in a Prometric exam centre of your choice.
This offer is valid until March 2009 - so go on, get the vouchers and start taking exams!
Have fun!

Monday, December 15, 2008

Changing fields by code - common oversight

I just helped someone on the OzMOss mailing list who had the following problem - he was trying to change a SPField object, but it was not getting updated, despite of no errors being thrown. Here is a sample of the code he was using:

Guid listID = web.Lists.Add("test", "", SPListTemplateType.PictureLibrary);
SPList list =web.Lists[listID];
SPField myField = list.Fields.GetFieldByInternalName("Title");
myField.Title = "TEST";
list.Update();
The problem with that code is a common oversight that developers who are new to the SharePoint object model usually make - the field object has to be updated. updating the list will have no effect, since the object that was modified was a column on the list, not a property of the list. The right code would be:
Guid listID = web.Lists.Add("test", "", SPListTemplateType.PictureLibrary);
SPList list =web.Lists[listID];
SPField myField = list.Fields.GetFieldByInternalName("Title");
myField.Title = "TEST";
myField.Update();

Tuesday, November 25, 2008

How to copy attachments from one list item to another

The microsoft support article for WSS 2 shows us how to download attachments from a list item. Basically, the attachments for a list item are stored as SPFile objects under a hidden folder in the list where those attachments are (a folder called "Attachments") - where each list item that has an attachment has its own folder - with the ID of the item being the folder's name. Here is a code sample for a function to copy attachments from one item to another.

private void CopyAttachments(SPListItem sourceItem, SPListItem targetItem)
{
  try
  {
     //get the folder with the attachments for the source item
     SPFolder sourceItemAttachmentsFolder =
         sourceItem.Web.Folders["Lists"].SubFolders[sourceItem.ParentList.Title].SubFolders["Attachments"].SubFolders[sourceItem.ID.ToString()];
      //Loop over the attachments, and add them to the target item
     foreach (SPFile file in sourceItemAttachmentsFolder.Files)
     {
        byte[] binFile = file.OpenBinary();
        targetItem.Attachments.AddNow(file.Name, binFile);
     }
  }
  catch { }
  finally
  {
     sourceItem.Web.Dispose();
  }
}

Thursday, November 20, 2008

Custom fields with custom properties - important link

If you have developed a custom field type that has custom properties, and now want to create a feature that uses that custom field (to add a site column for example) and want to set the custom property, you may be puzzled how to set the custom property, since the schema of the elements file does not allow it.

I found that Péter Holpár has a solution - I tested, and it works. Basically, just add the custom property with a custom name space - for example, using my datevalidator field type from my teched presentation, you can define it as a site column thus (important bits are highlighted):

<?xml version="1.0" encoding="utf-8"?>
<!--
-->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"
xmlns:custom="http://www.sharepoint-tips.com/customfields">
 <Field ID="{BBC8063E-252E-4fc0-9DC6-CA162512BB33}"
        SourceID="http://schemas.microsoft.com/sharepoint/v3"
        Type="DateValidationFieldType"
        Name="MyTestValidationField"
        StaticName="MyTestValidationField"
        DisplayName="My Test Validation Field"
        Group="Custom"
        Hidden="FALSE"
        ReadOnly="FALSE"
        Required="FALSE"
        RowOrdinal="0"
        custom:StartDateFieldName="Start Date"
        custom:EndDateFieldName ="Due Date"
 >   
 </Field>
</Elements>


I hope it solves your questions as well.

Thursday, November 13, 2008

Using the People picker - how to specify what can users choose

Just got this question in the Ask-The-Experts stand in Tech.ED europe. If I use the people picker like I showed in a previous article, how can I specify if the users can pick a user or a security group or a distribution list?

Well, the answer was in the SDK - there is a property "SelectionSet" that accepts a comma-delimited list of strings that say what can be picked.

For example, "User,DL,SecGroup" will allow users to pick user accounts, distribution lists and security groups. Choosing just "User" will allow only people accounts. The sharepoint people picker ususaly sets "User,SecGroup,SPGroup" or "User,SecGroup" or just "User"

Wednesday, November 12, 2008

My code for the custom fields presentation

As promised, here is the code I used. For the PowerPoint presentation I need to get approval, so wait for it.

The code has three samples of custom field types - one is a prime number validation field type (allows people to type only prime numbers), one is a date validation field that checks two other fields that the end date is after the start date (this is a good example for creating custom properties for the custom field) and the last is a sample how to create a custom look and feel for a custom field, without compiled code - just XML definition (CAML) in the renderpattern section. have fun!

Tuesday, November 11, 2008

Tech.Ed EMEA presentation

I just came out of my presentation in Tech.ED EMEA, and it was great fun! I showed how to develop custom field types, and was very well recceived. My current rating is 8.07 (which is pretty high, especially for a 400 level presentation) and here is some of the great feedback I got:
"I wish all teched sessions were this informative! Maybe some more time for questions."
"a fantastic engaging performance"
"Great session by Ishai Sagi. Keeping it to the topic and quickly answering questions in a good fashion. Great work. Kept me awake although I was rather sleepy (Jetlag? :-))"
"very good presentation, deep look inside sharepoint!!"
I am doing the same presentation again on thursday, and then I will be able to post the content here on the blog. anyone interested?