Tuesday, March 3, 2009

The data source control failed to execute the update command

I created a SharePoint list with one of the fields being a lookup to a field in another SharePoint list. The user wanted this DDL to be filtered. No problem. I can do that. So I created my filtered lookup (good instruction but not supported well). When I tried to update an item or insert a new item using the filtered lookup I received the error: The data source control failed to execute the update command. I found that the Microsoft Office Online website actually gave some instruction about this error:

From Insert a Data View as a Form at Microsoft Office Online:
"However, if your data source is an SQL data source such as an SQL database or a SharePoint list or library, the field types may be specified in the data source itself. In such a case, if you use the form to enter text in a field that requires numbers and then click Save, an error message appears in the browser explaining that the data source control failed to execute the update command. This means that you are entering values in the form that the data source field cannot accept. If you receive such an error message, click Back in the browser, and then either click Cancel on the form to discard your changes, or enter values in the form fields that the data source can accept."

Basically, I had to go back into my SharePoint list and delete that lookup column and re-create the column as a single line text type column. This did solve the problem. Unfortunately, this column, in its current state, only saves the text of the option value in the filtered lookup. Be warned: this column no longer saves the link to view the information of the lookup item. This was no great loss for my users and this solution allowed me to store the necessary information I needed in that column. By the way, no changes were needed to the filtered lookup on the NewForm.aspx or EditForm.aspx pages after this change to the SharePoint list.

Tuesday, December 23, 2008

SPD Workflow: Display Full Name Instead of Domain\username

I recently setup a SharePoint list and used the Person or Group list column type. I wanted to use proper names in emails sent by a workflow associated with this particular list. The only value I could get out of the field was domain\username. Unfortunately, using WSS 3.0, I have not found an OOTB way to grab the proper name of the individual users stored in this column type. So I created my own way to parse this data utilizing some other tips and tricks I’ve learned along the way. The basic premise is that we will be parsing the domain\user.name text string to get First Name and Last Name.


  1. Create a text column that will mirror the Person or Group column: hiddenColumn. We need this because we will be parsing the text string in this field. SharePoint will not allow you to reference a Person or Group column in a calculated field (see Step 2). I noticed that when I created my hidden columns if I unchecked the “Add to all content types” option then this column would not appear in the New Item or Edit Item forms.


  2. Create 3 calculated columns (see formulas below): First Name, Last Name, Full Name. I suppose you don’t have to create the Full Name calculated column since you can concatenate the other 2 columns whenever you need a full name but I chose to do so anyway. The formulas for the calculated columns: I learned that a SharePoint calculated column can contain almost every formula and/or function that exists in MS Excel. With that knowledge I was armed and dangerous and created the formulas below.
    Note: ## = the number of letters in your domain name including the "\"
    $$ = add 1 to value of ##, used as a starting poistion for string manipulation

    First Name =PROPER(LEFT(MID([hiddenColumn],$$,LEN([hiddenColumn])-##),FIND(".",MID([hiddenColumn],$$,LEN([hiddenColumn])-##),1)-1))

    Last Name =PROPER(RIGHT(MID([hiddenColumn],$$,LEN([hiddenColumn])-##),LEN([hiddenColumn])-FIND(".",[hiddenColumn],1)))

    Full Name =PROPER(CONCATENATE(LEFT(MID([hiddenColumn],$$,LEN([hiddenColumn])-##),FIND(".",MID([hiddenColumn],$$,LEN([hiddenColumn])-##),1)-1)," ",RIGHT(MID([hiddenColumn],$$,LEN([hiddenColumn])-##),LEN([hiddenColumn])-FIND(".",[hiddenColumn],1))))


  3. Create a workflow to store a “working” value in the hidden column that mirrors the Person or Group column. This is needed so we can manipulate or parse the text string value that is stored in the Person or Group column within the calculated columns. SharePoint will not allow you to perform calculations on a Person or Group co;umn type. This is a great video that explains exactly how to do this: Run a workflow when a specific field changes


This is a screenshot of my workflow