SharePoint Tip of the day – Don’t forget you don’t have a SPContext in your event receiver (synchroneous or asynchroneous)


… so whenever you're calling some utilities helper class from your receiver code, make sure they are not relying on the SPContext … (you can still have a classic httpcontext in your synchroneous event, that can be handy)

Advertisements

SharePoint Tip of the day – Open a Custom Action “EditControlBlock” in an overlayer


Customaction

People get really used to overlayers in SharePoint 2010. Altough you can turn it off at the list level, it’s a nice addition and you can easily benefit from it in your custom action development.

Here’s a quick snippet to open your custom action in a modal dialog. The trick is to use some inline javascript in the UrlAction (instead of a regular url) to call the dialog and manage the call back function. 

Tweak it to your needs !

SharePoint Tip of the day – Don’t forget to to disable the LoopbackCheck on your SharePoint VM / Server (even more if you use AAM !) (401.1 error)


I'm currently developping a solution that makes extensive use of web services to communicate back and forth between two site collections.
When I added Alternate Access Mapping to both site collections, I wasn't anymore able to call my web service locally (it still worked fine when called from another server). On the relevant server, trying to reach a site collection (and thus anything underneath) using the AAM name was always triggering the credentials prompt and failed regardless of the validity of the credential given…

Turned out the culprit was the LoopbackCheck (and if you need to disable it like me, add this key : [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlLsa] "DisableLoopbackCheck"=dword:00000001

Edit : once the culprit was known, google turned out to be more friendly in helping me !
Looks like there is a more secure way to fix this, and thus avoiding to disable the loopback check :
http://blogs.windwardreports.com/wunder_fodder/2010/03/sharepoint-gotcha-when-using-alternate-access-mappings-aam.html and you should read the excellent harbar post over there : http://www.harbar.net/archive/2009/07/02/disableloopbackcheck-amp-sharepoint-what-every-admin-and-developer-should-know.aspx to understand why it's a bad practice to do so on a production server.

SharePoint 2010 Tip Of The Day – Missing Translation Management Library template in your site


If you are missing the Translation Management document library on your site and you don’t see the relevant feature in the site collection features, don’t worry, the feature can still be activated :

stsadm -o activatefeature -name TransMgmtlib -url http://your-site-collection-url

you might then need to activate this feature as well if it was not already done at the farm level

stsadm -o activatefeature -name TransMgmtFunc -url http://your-site-collection-url

SharePoint Tip of the Day – Easily allow your contributors to see what an end user will see


A common requirement in all SharePoint projects that I’ve be working on is to see what an end-user / visitor will see. The publishing console have the option “preview in another window” but you need to have the console activated / displayed and it’s not always obvious for someone who doesn’t know where to look for such an option. Fortunately, it’s really easy to add a simple link in your page layout (or master page in any “toolbox area”), just use the current page url and append
?PagePreview=true, a target=_blank will finish the job to keep the current page being edited opened !

And if you want to add this to a site action button, you can simply reuse this snippet that I just did

    <CustomAction
      Id=”SiteActionsToolbar”
      GroupId = “SiteActions”
      Location=”Microsoft.SharePoint.StandardMenu”
      Sequence=”2001″
      Title=”Preview page in a new window”
      ImageUrl=”~site/_Layouts/Images/menuslideshow.gif” 
      RequireSiteAdministrator=”False”>
        <UrlAction Url=”javascript:window.open((window.location + ‘?PagePreview=true’), ‘Preview’, ”);” />
    </CustomAction>

Hope it helped !

 

 

SharePoint Tip of the Day – Users with Full Control permission level are not able to view / manage custom group membership


Even if you give the highest permission level (full control) to specific groups or users, they won’t be able to manage custom group memberships until they are set as the owner of the group. By default it’s the system account that is set as the group owner, and the only one allowed to manage the group, changing that settings will allow your specific group to manage itself.

Screenshot_000265

SharePoint Tip of the Day – Changing the execution timeout value


Edit (for all web servers in your farm) the web.config file in  C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12TEMPLATELAYOUTS and update the configuration / system.web / httpRuntime executionTimeout to something bigger (value is an amount of seconds)


No more dreaded execution timeouts after 6 minutes for your very long running synchronous operations ! (Thanks Peter !)

SharePoint Tip of the Day – Quick reminder to add the SharePoint 2007 or 2010 BIN path to your environment paths


In a command prompt either type / paste
@set PATH=C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12BIN;%PATH%
for SharePoint 2007

or
@set PATH=C:Program FilesCommon FilesMicrosoft Sharedweb server extensions14BIN;%PATH%
for SharePoint 2010

Edit : this will be lost when the command prompt will be closed, so you’re better of editing the environment varialble to add the bin path to it by going to

Control Panel > System > Advanced System Settings > Environment Variable > System Variables > Scroll to Path and click the Edit button and add ;C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12BIN (don’t forget the semicolon separator !)

SharePoint Tip of the Day – Ensure that the search crawler account that you are using is not a regular site collection user account !


Quick reminder because it took us a long time to figure it out, if you specify a limited (ie : reader member) account as the search crawler foolishly thinking like me that it would prevent the crawling of unaccessible page (admin page, anything unavailable thanks to the viewformpagelockdown, …) then stop doing so ! Any account specified as the search crawler account will be farm admin privileges (at least on the site collection crawled). That’s definitively not something you want to grant to your end-users 🙂

We never stop learning in SharePoint !

SharePoint Tip of the Day – Provide default value for your list instance with special characters.


Whenever you need to provide default values for your list that contains special characters like "<" "&" and so on, don't forget to encapsulate them in CDATA, neither the html entity name nor the entity number is working…

  <ListInstance
    FeatureId="{C6E862CB-BA2B-4976-A6B6-FFB162872F56}"
    Title="Power"
    Url="Lists/Power"
    Description="Power items list that will store and manage the various power values."
    OnQuickLaunch="TRUE"
    TemplateType="10001">

    <Data>
      <Rows>
        <Row>
          <Field Name='ID'>1</Field>
          <Field Name='Title'><![CDATA[<10W]]></Field>
        </Row>
        <Row>
          <Field Name='ID'>2</Field>
            <Field Name='Title'>10 – 50W</Field>
        </Row>
        <Row>
          <Field Name='ID'>3</Field>
            <Field Name='Title'>50 – 100W</Field>
        </Row>
        <Row>
            <Field Name='ID'>4</Field>
            <Field Name='Title'>100 – 150W</Field>
        </Row>
        <Row>
            <Field Name='ID'>5</Field>
            <Field Name='Title'>150 – 250W</Field>
        </Row>
        <Row>
            <Field Name='ID'>6</Field>
            <Field Name='Title'>250 – 600W</Field>
        </Row>
        <Row>
            <Field Name='ID'>7</Field>
            <Field Name='Title'><![CDATA[> 600W]]></Field>
        </Row>
      </Rows>
    </Data>

  </ListInstance>

François

SharePoint 2010 Tip of the day : Display your movies in an overlayer using the out of the box SilverLight media player.


Thanks to useful help of  Jomit, I managed to add an overlayer for the video.

Here’s what I did :

First : ensure that you have a reference the mediaplayer.js in your master page (if you want to reuse it in more than one page layout / page)

<script type=”text/javascript” src=”/_layouts/mediaplayer.js”></script>

(and don’t forget to end your script tag with a </script>, I spent several hours trying to understand why a <script … /> was not loading …

Second : once the  dom is loaded / ready (this is required otherwise the getElementById will return null and end the attachToMediaLinks function) trigger this : 

_spBodyOnLoadFunctionNames.push(‘mediaPlayer.createOverlayPlayer’);
mediaPlayer.attachToMediaLinks((document.getElementById(‘overlay_movies’)),[‘wmv’, ‘avi’]);

 

‘overlay_movies’ is the temporary div that I gave while testing, in my rendering I have something like :

 

<div id=”overlay_movies”>
   <ul>
      <li>
        a sample movie<br/>
     </li>
     …
   </ul>
 </div>

 

Videos

There comes a nice overlay player when you click on a media (with one of the extensions specified as parameter) in that div.

SharePoint 2010 Tip of the day – New Profile Picture Storage (and retrieval) mechanism


Sharepoint2010-17-40-02

Unlike the 2007 edition where the picture was stored on each user "my site", they are now hosted in a central library "User Photos" under your mysite url

So in order to access this repository, just point your browser to :
http://sharepoint2010/my/User%20Photos/Forms/AllItems.aspx (adapting the computer name / domain to your needs obviously)

Like all pictures libraries, uploaded images are resized in 3 dimensions (large, medium, small) and you can access a specific picture by using the url above with something like

"http://sharepoint2010/my/User%20Photos/{0}_{1}_{2}Thumb.jpg"  where {0} is the domain name, {1} is the login name and {2} is the requested size (L, M or S).

Now I need to find a way to retrieve the my site application url (from a sandbox solution, that will be … fun !)

François

SharePoint 2010 Tip of the day : Don’t forget to do a full crawl to be able to search / find the freshly imported profiles (from your AD or other source)


People_search

I had a very hard time this morning configuring the profile synchronization in SharePoint 2010 (damn, that thing is really fragile) but now my profiles are imported correctly from Active Directory.
I used a People Core Search Result webpart in my site collection and I was unable to retrieve any profile regarding of the settings that I used … Turned out that a full crawl was needing to harvest all profiles

If someone can explain me what's behind SPS3 and the "site$$$people" stuff that have been found by the crawler, I would be more than glad to know !

Reminder : Auto logon in Windows 2008 Server


  • Click Start, and then click Run.
  • In the Open box, type Regedt32.exe, and then press ENTER.
  • Locate the following subkey in the registry:
    HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon
  • Double-click the DefaultUserName entry, type your user name, and then click OK.
  • Double-click the DefaultPassword entry, type your password, and then click OK.NOTE: If the DefaultPassword value does not exist, it must be added. To add the value, follow

    these steps:

    1. On the Edit menu, click New, and then point to String Value.
    2. Type DefaultPassword, and then

      press ENTER.

    3. Double-click DefaultPassword.
    4. In the Edit String dialog, type your password and then click OK.

    NOTE: If no DefaultPassword string is specified, Windows automatically

    changes the value of the AutoAdminLogon key from 1 (true) to 0 (false), disabling the AutoAdminLogon

    feature.

  • On the Edit menu, click New, and then point to String Value.
  • Type AutoAdminLogon, and then press

    ENTER.

  • Double-click

    AutoAdminLogon.

  • In the Edit String dialog box, type 1 and then click OK.

SharePoint 2010 Tip of the day : What to do when you are unable to publish PowerPoint to a slide library ?


  • Go to Start->Administrative Tools->Server Manager
  • In Server manager Click on Features and the click Add Features
  • Select the Desktop Experience Feature and install it. Then Restart the Server (Required for installation of the feature)
  • Go to Start->Administrative Tools->Services
  • Select the Web Client Service and Start it.

Many thanks to Anshul who figured this out !

SharePoint Tip of the day – Unable to add users from your active directory ?


If you’re stuck with local accounts when you want to add new users to your SharePoint site, just make sure that the application account that you used for the specific web application has read access on the AD.
In a single server environment I was using a dedicated local account for the application pools, switching to a domain account solved the issue since the application pool account is the one that is use to query the Active Directory.

A small tip, but a huge relief !

SharePoint tip of the day – beware of the default 255 characters limit on your note field


If you want to store more than 255 characters in your note field (it’s filled quite fast, it’s slightly bigger than 1 sms message…) ensure that you add the UnlimitedLengthInDocumentLibrary=”TRUE” in your field definition otherwise you’ll be stuck when a user wants to enter more than 255 characters in the field (whether it is manually or programmatically)

Regular note field :
<Field Type="Note" DisplayName="FVE_A" Required="FALSE" NumLines="10" RichText="FALSE" Sortable="FALSE" Group="Custom Columns" ID="{9b4f21da-1777-49b9-9fee-12c06be43f78}" SourceID="{b1665635-4378-4ac1-947e-dd6592bb1cd1}" StaticName="FVE_A" Name="FVE_A"></Field>


Unlimited note field (max allowed by nvarchar in SQL)

<Field Type="Note" DisplayName="FVE_B" Required="FALSE" UnlimitedLengthInDocumentLibrary="TRUE" NumLines="6" RichText="FALSE" Sortable="FALSE" Group="Custom Columns"

ID="{c80e9e77-3e06-4404-81d1-af07c6210bad}" SourceID="{b1665635-4378-4ac1-947e-dd6592bb1cd1}" StaticName="FVE_B" Name="FVE_B"></Field>

SharePoint Tip of the day : Manage default value in your custom field type


I took me quite a long time figure out why my <defaultvalue> property of my custom field type was not taken into account. It turned out that I need to do a little bit of work in my overriding of the CreateChildControls of my field control.
Basically, we are checking the field has actually no value (to avoid overriding a previously set value) through base.ListItemFieldValue and also if a default value was provided in the field xml definition (or programmatically).

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            if(ControlMode== SPControlMode.New || ControlMode == SPControlMode.Edit)
            {
                string currentValue = (base.ListItemFieldValue == null ? string.Empty : base.ListItemFieldValue.ToString());
                if (string.IsNullOrEmpty(
currentValue) && !string.IsNullOrEmpty(Field.DefaultValue))
                {
                    base.ListItemFieldValue = Field.DefaultValue;
                }
            }
        }

Sweet !

SharePoint Tip of the Day : Render a link within a SPGridView


    <SharePointWebControls:SPGridView runat="server" ID="spgridviewApprovalTasks" DataSourceID="dataSourceApprovalTasks" AutoGenerateColumns="false" EmptyDataText="<p><i>Nothing is waiting for approval.</i></p>">
         <Columns>
             <asp:BoundField HeaderText="Task" DataField="Task" />
             <asp:BoundField HeaderText="Created on" DataField="Created on" />
             <asp:BoundField HeaderText="Description" DataField="Description" HtmlEncode="False" />
             <asp:BoundField HeaderText="Status" DataField="Status" />
             <asp:BoundField HeaderText="Comments" DataField="Comments" />
             <asp:TemplateField HeaderText="Page">
                 <ItemTemplate>
                      <a href='<%#new SPFieldUrlValue(Convert.ToString(Eval("Element To Approve"))).Url%>' style='white-space:nowrap'>&rarr; view the media</a>
                  </ItemTemplate>
             </asp:TemplateField>
         </Columns>
    </SharePointWebControls:SPGridView>

Now I have to remember how to use the field name instead of display name within the SPGridView because it's damn ugly to rely on the display name !