How to change SPListItem Created or Modified date

Another often asked question is a ‘How to change SPListItem Created/Modified date’. Such taskĀ occur when you importing documents to the SharePointĀ Ā from another source when you want to save authorshipĀ and time information.

To update Created and Modified date you can use SPListItem indexer to modify infomation and call Update() to save changes.

To modify CreatedBy and ModifiedBy properties, you can use SPListItem indexer to modify fields with internal names Author and Editor. But you should convert SPUser object into string with following format “{userId};#{userName}”

Example you can find below:

public void ApplyMetadata(SPListItem item, DateTime created, DateTime modified, SPUser createdBy, SPUser modifiedBy)
{
  item["Created"] = created;
  item["Modified"] = modified;

  item["Author"] = GetStringByUser(createdBy);
  item["Editor"] = GetStringByUser(modifiedBy);

  item.Update();
}

private static string GetStringByUser(SPUser user)
{
  return user.ID + ";#" + user.Name;
}

Visual Studio minimap

When I saw a Sublime Text 2 with their features at first time – I loved that. One of my favorite feature is a minimap.  It is a simple but very powerful idea to replace scrollbar with minimized code map. Using this feature very easy navigate directly to where you want.

I wanna this feature for Visual Studio for sure. Fortunately, it is already there. It is a part of the Productivity Power Tools.

First of all we need to setup Productivity Power Tool using Visual Studio Extension Manager.

We need to enable this feature, because it is disabled by default.  Open Tool -> Options -> Productivity Power Tools, enable Enhanced Scroll Bar and restart your Visual Studio.

Choose ‘Full map mode‘ in the Productivity Power Tools->Enchanced Scroll Bar section.

You should see minimaps in your Visual Studio now. Enjoy it!!!

How to integrate F# and Notepad++

People a faced with challenges trying to install F# interactive plugin for Notepad++ (example). I am not an exception, going through all of this I want to share my experience.

  1. First of all download latest version of theĀ Notepad++Ā and install it (default installation settings). For today it is Notepad++ 6.1.5 (Jul 16 2012)
  2. DownloadĀ NPPFSIPluginĀ Version 0.1.1.
  3. ExtractĀ dll fromĀ achieveĀ and copy it toĀ Notepad++\plugins\Ā folder.Ā On the my Win7 64bit machine it is c:\Program Files (x86)\Notepad++\plugins\.
  4. Open or re-open you Notepad++ application.
  5. GoĀ toĀ Plugins\F# Interactive\OptionsĀ menu item.
  6. Specify Binary Path to fsi.exe file.
    For example:
    F# 2.0C:\Program Files (x86)\Microsoft F#\v4.0\fsi.exe
    F# 3.0Ā –Ā C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\fsi.exe
    Before use thisĀ paths check that you you have installed appropriate version of F# in thatĀ 
  7. Save you changes. Now it should work.
    Alt+TĀ to open F# interactive
    Alt+EnterĀ to to send selected text to F# Interactive

It is also very nice to have a F# syntax highlighting.

  1. Download xml file with user definition language for Notepad++ fromĀ hereĀ orĀ here.
  2. Rename file toĀ userDefineLang.xml.
  3. ReplaceĀ Ā ext=”fs”Ā Ā toĀ Ā ext=”fs fsi fsx”Ā Ā in the file.
  4. Copy this file toĀ %APPDATA%\Notepad++\Ā folder. (for moreĀ details goĀ hereĀ )
    Path should be like this :Ā C:\Users\User_Name\AppData\Roaming\Notepad++
  5. Restart Notepad++.

Note: If you already have such file open both. (instructions is copied fromĀ here)

  1. Select all of the new file, copy, and paste at the end of the current file
  2. DeleteĀ Ā </NotepadPlus><NotepadPlus>Ā pair in the middle (remove 2 lines)

P.S. Post moved fromĀ http://sergey-tihon.blogspot.com/