Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Wednesday, February 15, 2012

Error when adding a Record Center site

When adding a Record Center to a SharePoint Server installation you may see the error “Dependency feature ‘DocumentRoutingResources’ … is not Activated

DocumentRoutingResources_Error

The feature is a hidden feature and can not be enabled in the GUI’s

To enable this feature start the “SharePoint 2010 Management Shell” (Power Shell) located in the start menu in “Microsoft SharePoint 2010” folder.

Copy/type the following command to enable:

Enable-SPFeature -Identity "DocumentRoutingResources" -Url http://yoursiteurl

 

RecordsCenter

Tuesday, May 10, 2011

Workflow - Use url when creating a link in workflow steps

This may be obvious, but if you choose text instead of url in a link that you create in SharePoint Designer you can get an invalid link since the text version also includes the title

Ex: “http://mysite.mydom.com, Link Title”

In my case a link already existed in a SharePoint ListItem as a valid URL. But when added as a link in a mail the url got the trailing comma and title. Which in turn gave the webserver an invalid parameter.

The link that should have been:

…/wi.aspx?pcguid=d6d9eacb-0d67-4b19-ad62-626ab5cc1cf0&id=916

became

…/wi.aspx?pcguid=d6d9eacb-0d67-4b19-ad62-626ab5cc1cf0&id=916,%20Click%20to%20open%20the%20WorkItem%20in%20TFS

and the TFS Web did not like ID’s with comma and text…

Url

Friday, May 6, 2011

Remember to modify default.aspx after enabling “Wiki Page Home Page”

When enabling this feature you are modifying the default homepage of your site. The homepage will go from …/Default.aspx to …/SitePages/Home.aspx

When users have added bookmarks using the default.aspx homepage the users will still use your old homepage.

Quickfix edit the default.aspx file using SharePoint Designer and make a redirect to the new page. Or just add a Content editor and insert a script or descriptive text to update bookmarks

Thursday, March 3, 2011

CAML Query and User Groups – Membership

While creating a Timesheet webpart I needed to list a users tasks in a task list. The tip from Martin Hatch gave the basics. and the query executed fine in U2U CAML Query Builder (2007 version works fine for 2010)

<Where>
  <Or>
    <Eq>
      <FieldRef Name='AssignedTo' />
      <Value Type='UserMulti'>User Display Name</Value>
    </Eq>
    <Membership Type='CurrentUserGroups'>
      <FieldRef Name='AssignedTo' />
    </Membership>
  </Or>
</Where>


This query will return users in groups, and multiple users specified in the field:


Users and Groups


Note:



The Membership attribute checks current user, so do not run the query with elevated rights (SPSecurity.RunWithElevatedPrivileges(…)



Unless you assign tasks to your application pool the query will not return items based on group assignments

Wednesday, January 26, 2011

SPFieldUser is not persistent during postback

If you are using a custom listform and refering to a field of type SPFieldUser. The field tend to loose the content (users) during postback. Some times not easily detected because it will keep the viewstate sometimes.

This has been seen on versions 2007 and 2010.

The fix is relatively simple, by putting the contents into the viewstate in code.

Example:

In the listform.aspx

<SharePoint:FormField runat="server" id="Fld_Present" ControlMode="Edit" FieldName="Present" />

Snippets from codebehind

protected FormField Fld_Present; // Define the field in codebehind

// Define a private String for holding the value during postbacks

 

private String Present

{

    get

    {

        object obj = ViewState["Present"];

        return (obj == null) ? String.Empty : (String)obj;

    }

    set

    {

        ViewState["Present"] = value;

    }

}

 

protected override void CreateChildControls()

        {

            base.CreateChildControls();

 

            if (Fld_Attendees.Value.ToString() != "")

                this.Attendees = Fld_Attendees.Value.ToString();

            else

                Fld_Attendees.Value = new SPFieldUserValueCollection(SPContext.Current.Web, this.Attendees);

 

To keep values when the user field is edited, also add some code before postbacks that is defined in codebehind:

 

if (Fld_Attendees.Value.ToString() != "")

                    this.Attendees = Fld_Attendees.Value.ToString();

 

Thursday, January 20, 2011

Convert ListItem ID to UniqueID

This is just one way of getting from the ListItem ID (Not Index) to the GUID UniqueID

In SharePoint 2010 you can use SPList.GetItemByIdSelectedFields(…) or SPList.GetItemByIdAllFields(…)

Example:

GetItemByIdSelectedFields(Int32.Parse(this.ListItemID), new string[] { "UniqueId" });

If you don’t have 2010 you can always retrieve the ListItem with a CAML Query…

Tuesday, December 14, 2010

Change View headers in SharePoint 2010

For changing the view Headers you need the SharePoint 2010 Designer.

To start modifying your view select the “Edit List in SharePoint Designer” or simply open the designer and navigate to your list

SNAGHTML1ee2bedd

Click on the placeholder that has the View Web part to enable the ribbon tools.

SNAGHTML1ee7bfb8

Click List View Tools –> Design, and Choose Customize XSLT – Customize Entire View,  to enable editing of the xslt.

SNAGHTML1ee9f394

Click on a header, and replace the xslt in the codeview. The default xslt will be <xsl:value-of select="$fieldtitle"/> replace with something like <xsl:text disable-output-escaping="yes">Your new header</xsl:text>

Now for the important part:

You must remove all ddwrt:ghost="hide" attributes in your view. If these attributes exists the view will not be correctly saved. Do a search replace and save the “file”.

Before:

SNAGHTML1ee50b29

After:

SNAGHTML1ef12b85

Friday, November 12, 2010

Custom List Form with version history

When turning on version history on a list that is using custom list forms the text entered in a multiple line textbox is not displayed. when the field is in Display mode. The text just seems to be lost in the database. But by examining the version history for the item you will see all the changes.

The solution is simple:

In order to display the history use another control type, use the <SharePoint:AppendOnlyHistory/> instead of <SharePoint:FormField/>

By using this control you will get a nice list of all the field versions.

And by combining the two you can get a field that displays the history, and at the same time give the possibilities to edit the text:

TFS_Bug_with_history_full

Tuesday, November 2, 2010

IsDlg=1 numeric value is not validated

When using SP.UI.ModalDialog.showModalDialog(…) you should set the parameter IsDlg to 1 when calling a List Form (View/Edit/Create) this removes all references to masterpage items such as quick launch etc.

Keep in mind that the numeric value entered after the IsDlg has no effect, so setting IsDlg=0 is the same as IsDlg=1 SharePoint only checks for the existence of the variable IsDlg and does not check if the value is set to anything. So leave out the IsDlg entirely when the page is loaded without popup windows

Wednesday, July 28, 2010

Connecting to TFS2010 from a Webpart

With the implementation of Team Foundation Server 2010 the need for some integration with SharePoint 2010 was needed. Just to test the TFS API a simple webpart for registration of User Stories from SharePoint was created.

New to the TFS API I discovered that connection to the Project Collection needed a ICredentialsProvider (Fallback).  The UICredentialsProvider works fine in Windows Applications but when using the web, this provider can not be used…

The first step is to create a new Interface that uses the NetworkCredential class to return the credentials

public class NetworkCredentialsProvider : ICredentialsProvider
    {
        private readonly NetworkCredential credentials;
        public NetworkCredentialsProvider(NetworkCredential credentials)
        {
            this.credentials = credentials;
        }
        public ICredentials GetCredentials(Uri uri, ICredentials failedCredentials)
        {
            return this.credentials;
        }
        public void NotifyCredentialsAuthenticated(Uri uri)
        {
        }
    }

Use this Provider to connect to the Project Collection

ICredentialsProvider TFSProxyCredentials;
var credentials = new NetworkCredential("Username", "Password", "Domain"); TFSProxyCredentials = new NetworkCredentialsProvider(credentials);

var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(projectCollectionUri, TFSProxyCredentials);

When running this code from a webpage/webpart the TFS will return an exception: “TF237121: Cannot complete the operation. An unexpected error occurred.”

This Exception is occurs because the TFS Client does not have a reference to a local Cache for storing files. (Normally this is stored in the current user profile area)

The solution is to let the TFS Client know where to store cache-files. This is done by defining a application setting named WorkItemTrackingCacheRoot and specifying a local path on the server (With proper NTFS rights)

The application setting can be created in web.config or programmatically

web.config:

<appSettings> <!-- Add reference to TFS Client Cache -->
   <
add key="WorkItemTrackingCacheRoot" value="C:\TFSClientCache"
/> </appSettings>

Code:

if (WebConfigurationManager.AppSettings["WorkItemTrackingCacheRoot"] == null || WebConfigurationManager.AppSettings["WorkItemTrackingCacheRoot"] == String.Empty)
{
   WebConfigurationManager.AppSettings["WorkItemTrackingCacheRoot"] = System.IO.Path.GetTempPath() + "TFSClientCache";
}

Thanks to Naren’s blog for pointing out the Client Cache settings

Click to download complete code to connect, and to get project info

 

Friday, October 30, 2009

SharePoint Indexing - mssdmn.exe is using 100% CPU

After experiencing a slow SharePoint system it was discovered that the process mssdmn.exe was consuming all available CPU. (Frontend and Indexing service on same server)

SharePoint indexing was correctly configured, and performance configured not to use all CPU…

The resolution in this case was to install the latest IFilters for Office from Microsoft and the latest IFilter for Adobe PDF from Adobe (Version 8 and 9 has also support for for 64-bit systems)

Note: To compare Foxit and Adobe see the “Jie Li's GeekWorld (BLOG)

After installing the filters, and changing the ObjectID in registry for PDF files (See documentation at Adobe (Page 2)) The process started indexing, and stopped consuming CPU after the indexing tasks were finished…

No need to restart the server, just restart the Search Service and the IIS

  • net stop ossearch –> net start ossearch
  • iisreset /noforce

Wednesday, October 21, 2009

Error when opening a list in Datasheet View

“Access web datasheet is attempting to retrieve data from a different domain…”

When seeing this error message I first thought of cross domain access using JavaScript.

By checking the field types of the dropdowns that did fail I discovered that the only fields that failed was lookup fields that uses other tables as data source, other dropdown menus that where static worked fine. The lookup fields returned blank in datasheet view, but worked  in a normal list view.

By examining the links that the site presented I saw a combination of links pointing to different server names. ex: the user entered intranet in the address field in the browser and some links where pointing to the server name (Without the domain suffix or zone)

The problem: Alternate Access Mappings were not configured for the alias intranet. Therefore the server returned different links. And to my understanding this was the case for the error message, and the empty lookups.

The Solution: Add a internal URL in the Access Mappings located in the SharePoint Central Administration->Operations->Global Settings->Alternate Access Mappings that points to the alias (intranet)

After adding a new url to the access mappings the datasheet view returned correct values in the lookup fields.

Thursday, September 24, 2009

Can not enable anonymous access for internet zone

Just to clarify the relationship between alternate access mappings host headers and SharePoint Zones…

While configuring multiple frontend servers and different zones, including Internet. I discovered that I could not set the anonymous access to my site in the Internet Zone.

What puzzled me was the fact that I could not set the anonymous access rights on the site after enabling anonymous in the Zone. The choices were all disabled. (_layouts/setanon.aspx)

Not_Anon

Not having my mind correctly set I missed the fact that I was configuring the site collection using a url that was NOT configured for the Internet zone. I was only configuring using the default zone (or the server name as host to be specific)

The host header and the alternate access mappings is the only link that SharePoint has to discover that the site actually is in a zone. It all makes sense, but when you are configuring your site before the DNS entries are set you may stumble on this little problem…

By using the correct hostname, that is referring to the internet zone in my browser it all worked out.

OK_Anon

Tuesday, September 22, 2009

ASP.NET error after installing a SharePoint WFE

After installing a new SharePoint Web Frontend you  receive a “normal” ASP.NET error message the address in the browser will point to the _Layouts “directory”, so SharePoint is in play.

When studying the event log the message contains “Could not load file or assembly RSSharePointSoapProxy…

This is a Assembly that is used by the SQL Server Reporting Services Integration for SharePoint.

The problem: Reporting Services is installed on the SharePoint Farm and the binaries does not exist on the new frontend server.

Solution:

Start by downloading the Microsoft SQL Server Reporting Services Add-in for Microsoft SharePoint Technologies for SQL 2005 or SQL 2008 (May 2009 release) (SharePointRS.msi or RSSharePoint.msi)

Note: The description below is based on the 2008 version of the Add-in

Do not run the MSI as a ordinary setup process, this will result in a error message in the event log and a rollback of the package. The error indicates that the SERVERNAME$ can not logon to the database.

Start the MSI with the parameter SKIPCA=1 this will extract the file rsCustomAction.exe to the TEMP folder of the current user.

To install the binaries and configure the Reporting Services run rsCustomAction.exe /i

Be sure to run as a user that has rights to the SharePoint Site Collection.

After the executable finishes your new SharePoint Front End should display the SharePoint sites normally.

By running this application the Solution will be redeployed on the existing servers as well, even upgraded if possible.

For more information see the readme bundled with the Add-in

Access denied when configuring SharePoint WFE

When adding a new Web Front End Server to a SharePoint Farm you may get a access denied error in step 2 when connection to the configuration database. This error will occur regardless of the configuration entered before the configuration begins. (The search for configuration database is successful.)

Configuring_SharePoint

Before starting SQL Management Studio or another tool to check permissions on your database server. Check the version of the existing SharePoint environment.

You will get this error if the new SharePoint server binaries is another version than the existing system. Remember to update the SharePoint installation (Both WSS and MOSS) before running the SharePoint Products and Technology Configuration Wizard.

Refer to the SharePoint AdminWiki to get your SharePoint Version.

Monday, August 24, 2009

Error when configuring SharePoint Services Search Service

You probably know this already this is just a notice to self :-)

When configuring a SharePoint Services Server running everything locally you normally specify the user accounts only by the username during the installation and configuration.

When looking at the Services in the server you notice that there is one service that is not starting. The “Search Service”. You click on the start link and the configuration page pops up. You enter all the user settings and click on start. After a second or two a rather generic error message appears SPSearch(Username).

After rechecking passwords and usernames you try again, with the same result…

The problem is that the “Service Account” username must have domain\user or server\user syntax (server\user in this case)

The “Content Access” Account can be specified using the username only (But it does not hurt to add the server name as well)

Search_Service_Account

Friday, July 31, 2009

Tweaking the Quicklaunch menu with JQuery

The standard Quicklaunch menu or the <SharePoint:AspMenu> has some limitations regarding layout and dynamic display… Microsoft has released the code to the menu in order to make the menu more customizable (The reason for the publication of the source code is the the fact that the control is marked as sealed and is therefore not eligible to be used as the base class for derived types.) Read my other post on how to use this code to highlight the selected menu items.

When using a WSS environment the menu has further limitations regarding the url of a root element. The “problem” is that all menu items must have a url. The easy fix for this is to make all your level one URL’s like “/#” This will result in a link to the same page, but there will be a postback when a user clicks on the link.

In some scenarios you do not want, or you can not modify SharePoint using Features and compiled code.

So how do we modify the menu without writing any C# code? We use the JQuery library to parse and tweak the HTML already generated by the aspmenu control

The main part of the JQuery code is made by Paul Grenier and filed at EnduserSharePoint.com. Be sure to check out the other JQuery and SharePoint related articles!

The solution looks like this when finished

JQuery_Menu

To make the menu look like this I used one JavaScript library, a modified CSS file and a modified Masterpage. The masterpage modifications is minor and not a part of the dynamic experience…

The masterpage was modified to link to the two java libraries used, one for the JQuery library and one for the script from Paul Grenier.

linking_JQuery

I have modified the script a little in order to make the empty headers act as you clicked on +/- (The modifications are simple and can surely be made better, but it is my first JQuery Code)

JQueryMod

When a link is modified in SharePoint Services and the address is /#! the link will not behave like a normal link but expand/collapse instead.

jquery_empty_link

This was a big eye opener and definitely my start down the “JQuery Lane” It is so much you can do with so little code…

The files used can be downloaded here

Monday, June 15, 2009

Do not forget the <Query> in your Queries

When programming using the SharePoint WebServices you often want to write a CAML query to select items from a list etc.

When developing using the SharePoint API you do not need to write the surrounding <Query> tags. But when you submit a query to a webservice ex: lists.asmx the tags must be present.

Without the query tags the response will contain a soap exception.

It took me a while figuring this out as I was copying some C# code from an evenhandler to select items, into a Delphi app consuming the Lists webservice.

query

Wednesday, February 18, 2009

Show document icon using XSL and DDWRT


When displaying a document icon using XSL you may have tried to just map the image from the /_layouts/images folder using the file extension. This will work in most cases but it will not map PDF files etc. unless you add the images or edit the file mappings.

The ddwrt library has just this function made for you:

include a reference to the library in your xslt:

xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"

This is a snippet that includes the icon and sets the correct icon if the “file” is a folder:

<a href="{@FileRef}">
<xsl:choose>
<xsl:when test="@FSObjType=1"> <!-- Folder -->
<img alt="{@Title}" src="/_layouts/images/folder.gif" style="vertical-align: middle;border:none;"/>
</xsl:when>
<xsl:otherwise>
<img alt="{@Title}" src="/_layouts/images/{ddwrt:MapToIcon('', string(@File_x0020_Type))}" style="vertical-align: middle;border:none;"/>
</xsl:otherwise>
</xsl:choose>
</a>




Folders presented in xsl 

Monday, January 12, 2009

Get the Site ID in an event handler (SPItemEventReceiver)

While creating an event receiver for a list that is used to replicate project status I discovered that the SPItemEventProperties did not return what I expected.

I use the SiteID to recognize the list item when doing a update. The receiving list should only have one list item (status) for each reporting project site. To identify the site I was planning to use the property SiteId

SiteID

After reporting the status from two different sites I discovered that the receiving list only contained one list item. It should have contained two, one for each site.

Some more research discovered that the siteId is the ID of the root site, not the site where the event occurred.

Needing the SiteID of the site where the event occurred I tried using the OpenWeb() function instead

WebSiteID

The ID returned what I needed, and the event receiver reported successfully status for each subsite. I guess this just adds one more situation where you can get a little confused in the use of the terms site and web in SharePoint