Sitecore Error (SOLVED): An item name cannot contain any of the following characters: \/:?”\-|[] (controlled by the setting InvalidItemNameChars)

You may have ran into an issue during deployments when trying to publish in the past where you have seen this message:

“An item name cannot contain any of the following characters: \/:?”<>\-|[] (controlled by the setting InvalidItemNameChars)”

In order to help move forward on this you need to disable the default ItemNameValidation settings if you are having some deployment issues.

To do that (would only recommend temporarily) you can follow the steps below:

Add a config file to App_Config/Include named z.DisableItemNameValidation.config and put this in it:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <setting name="ItemNameValidation">
        <patch:attribute name="value"></patch:attribute>
      </setting>
    </settings>
  </sitecore>
</configuration>

Again, when you are finished I would recommend taking this back out of your files to keep things as standard as possible.

Help! Need Help Diagnosing A 500 Errors In SharePoint? Try This…

Imagine the nightmare…you decided to sneak in a web part deployment in right before the start of the business day. Right after your deployment you see that the site is about to come back up…and…then nothing. A blank screen. In desperation you open Internet Explorer to try and see if it loads there as well..nothing but a 500 error. Then, the feeling rushes over you that this was a very bad decision. While we should address why you were doing an early morning deployment we shall spare you. 🙂 So what do you do now?

One of the best ways to see what is going on with a 500 error is to enabled Failed Request Tracing in IIS for the web site in question. Once enabled you can replicate the issue by refreshing the browser a few times; this should be more than enough to capture a few. Once captured then you will usually see where the issue is identified (especially with web.config changes that happen).

To do this:

1) Open IIS

2) Select the web site in question and open the Features View

3) Under the IIS section select “Failed Request Tracing” by double-clicking it

FRT1

4) In the top right hand corner click the message in the Alerts section

FRT2

5) When the pop-up comes up then select to enable and take the default directory (unless you need it elsewhere, then specify another location) and hit OK

FR3

6) Next, under actions select “Add…” and select “All content (*)” and click Next

FRT4

7) Indicate the status code of 500 (and others where applicable) and click next again

Frt5

8) Indicate your trace providers and click Finish

FRT6

You should now see your created Failed Request Tracing Rules.

FRT7

Now go and refresh the browser a couple times to see your error again. Once that is logged then go to the trace logs. To find that location go back to the site in features view, select Failed Request Tracing and select “View Trace Logs…”

FR8

Double click to view the recorded log (you can use IE):

FRT9

Viewing these should at least help to identify the obvious when it is a line in the web.config or when there has been a setting changed as a result of saving a configuration option in SharePoint (or 3rd party products or web parts in SharePoint). Hope this helps, happy troubleshooting. Questions are always welcome.

 

How To Make A SharePoint List System.String Column (Built From An BCS External Content Type List) Into A Clickable Hyperlink

So for this example I have a SQL database that I am pulling into an external content type called OfficeLocations. From this external content type I have created a SharePoint list that is referencing it. The issue I ran into is that the GoogleMapLink text coming from SQL was in a NVARCHAR format (which was System.String on the external content type and Single line of text for the column) and you cannot modify those columns.

officelocationslistsetting

This left me with a list that had a link but it was not clickable:

officelocationslistsetting1

Annoying right? So what do we do? Let’s mess with the XSL template of the item and see what happens…so I popped into SharePoint designer and created a view off of the SharePoint list and modified the XSL template of the GoogleMapLink column to use the string field as the href of the <a> tag and supplied my own text to give the link a more user friendly readable URL.

To the code (the bolded elements are the only additions I made):

<xsl:template name="FieldRef_Text_body.GoogleMapLink" ddwrt:dvt_mode="body" match ="FieldRef[@Name='GoogleMapLink']" mode="Text_body" ddwrt:ghost="hide">
 <xsl:param name="thisNode" select="."/>
 <xsl:variable name="currentValue" select="$thisNode/@*[name()=current()/@Name]" />
 <xsl:choose>
 <xsl:when test="@AutoHyperLink='TRUE'">
 <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping ="yes"/>
 </xsl:when>
 <xsl:otherwise>
<strong><xsl:element name="a"></strong>
<strong> <xsl:attribute name="href"></strong>
 <xsl:value-of select="$thisNode/@*[name()=current()/@Name]"/>
<strong> </xsl:attribute></strong>
<strong> <xsl:text>Link</xsl:text></strong>
<strong> </xsl:element></strong>
 </xsl:otherwise>
 </xsl:choose>
 </xsl:template>

This created clickable links titled “Link” on the list itself. You can see the results below:

officelocationslistsetting2

Much cleaner, right? If you wanted the full link you could do that too. Hope that helps.

Add An Item To A Custom SharePoint List Using Batch XML With A Web Service (C#)

If you have multiple active directory environments and SharePoint instances in both of those environments then you will understand why I posted this.

I received a requirement that while users from a separate domain and SharePoint instance would need to fill out a form on their SharePoint and have the form submission be sent to the other SharePoint instance (on the other domain). This was because they did not want to mix and mingle with forest trusting or having users to have two separate AD accounts to manage the information. Say what?!

After some initial discovery I had reached a couple quick conclusions:

– SharePoints on different domains do not talk well to each other without trust

– Using the built-in lists service on SharePoint has to be done on the server itself unless you are going to have an instance stood up somewhere on the same domain that has all the required SharePoint dlls to be referenced

All being said, here is an example of what I used as a web service I placed on the SharePoint server that calls the lists web service doing a list add using batch XML:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Administration.Claims;
using Microsoft.SharePoint.WebControls;

namespace CopyOverItemFromOtherSP
{

{
public string CopyOverFromOtherDomain(string userName, string Name, string userEmail,
string userPhone, string listColumn1, string listColumn2, string listColumn3,
string Comments)
{
Boolean done = false;

/* Declare and initialize a variable for the Lists Web service. */
sitesWebServiceLists.Lists listService = new sitesWebServiceLists.Lists();

/* Authenticate the current user by passing their default credentials to the Web service from the system credential cache. */
listService.Credentials = System.Net.CredentialCache.DefaultCredentials;

/* Set the Url property of the service for the path to a subsite. */
// Service URLs - MUST CHANGE TO POINT TO SPECIFIC SERVICE ENVIRONMENT
// Change the web reference URL on the sitesWebServiceLists web service reference to be the address
// that you are wanting to used based on the environment that you want to write to
listService.Url = "<a href="#">http://sharepointtocopyitemto/_vti_bin/Lists.asmx</a>";

/* Get Name attribute values (GUIDs) for list and view. */
System.Xml.XmlNode ndListView = listService.GetListAndView("NameOfSharePointList", "");
string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;

/* Create an XmlDocument object and construct a Batch element and its
attributes. Note that an empty ViewName parameter causes the method to use the default view. */
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement batchElement = doc.CreateElement("Batch");
batchElement.SetAttribute("OnError", "Continue");
batchElement.SetAttribute("ListVersion", "1");
batchElement.SetAttribute("ViewName", strViewID);

/* Specify methods for the batch post using CAML. To update or delete,
specify the ID of the item, and to update or add, specify
the value to place in the specified column. */
batchElement.InnerXml = "<Method ID='1' Cmd='New'>" +
"<Field Name='ID'>New</Field>" +
"<Field Name='Title'>" + userName.ToString() + "</Field>" +
"<Field Name='Name'>" + Name.ToString() + "</Field>" +
"<Field Name='userEmail'>" + userEmail.ToString() + "</Field>" +
"<Field Name='userPhone'>" + userPhone.ToString() + "</Field>" +
"<Field Name='listColumn1'>" + listColumn1.ToString() + "</Field>" +
"<Field Name='listColumn2'>" + listColumn2.ToString() + "</Field>" +
"<Field Name='listColumn3'>" + listColumn3.ToString() + "</Field>" +
"<Field Name='Comments'>" + Comments.ToString() + "</Field>" +
"</Method>";

/* Update list items. This example uses the list GUID, which is recommended,
but the list display name will also work. */
try
{
listService.UpdateListItems(strListID, batchElement);
done = true;
}
catch
{

}
if (done == true)
{
return done.ToString();
}
else
{
return done.ToString();
}
}
}
}