Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 7025

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 2162

Deprecated: Hook imagify_allow_picture_tags_for_webp is deprecated since version 2.2! Use imagify_allow_picture_tags_for_nextgen instead. in /www/collab365_296/public/wp-includes/functions.php on line 5758
Workflow throws an error when you try to update or delete to a BCS external list - Collab365
Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Warning: Undefined array key "url" in /www/collab365_296/public/wp-content/plugins/thrive-visual-editor/thrive-dashboard/inc/smart-site/classes/class-tvd-smart-shortcodes.php on line 85

2014-11-28

One of the things I love best about SharePoint is I am always learning something new every day. In my experience, when things work right the first time you try something, you don’t learn much. Conversely, when things don’t work correctly, I learn tons of stuff. ‘Nuff said about learning opportunities in SharePoint.

I recently was working with a customer who wanted to use BCS to update records in an external database. After some initial research I learned I could use a workflow to update an external list (http://msdn.microsoft.com/en-us/library/office/ff394479(v=office.14).aspx).

I set up a test table in a SQL database, created the External Content Type in Designer, and after a few minor errors that I was able to figure out, was finally able to display the SQL database in SharePoint through an external list. Hurray! However, when I ran a workflow to update a record, the workflow would fail with the following error: “An error occurred in the UpdateRecord Workflow”. Not real helpful, right? So I went through the log files, Googled the problem, did a lot of reading but came up snookered. I finally opened a MSDN help ticket and through the course of 3 months and many hours of phone conversations with a variety of tech support people, they finally were able to debug the problem as a data type mismatch. Here is the tech’s explanation:

I was able to debug and confirmed the root cause of the problem is because the backend SQL DB table has nchar as the data type for the ID field.  The reason for that is because in the call stack shown below, the condition that evaluates whether the field value looked up from external list matches with the value we specified does not pass because the comparison is between:

“1         “ == “1”

Internally we always do a string comparison.  Since the values of the ID field has the data type nchar, the actual value becomes “1         “ instead of just “1”.

To mitigate this problem, I suggest two approaches:

  1. Use integer data type for identity fields when possible (recommended)
  2. Use nvarchar instead of nchar as that will ensure the trailing spaces are trimmed and the above validation will succeed

Hopefully this solution will shave several months off of someone else’s BCS troubleshooting ordeal.

 

(Visited 170 times, 1 visits today)

About the author 

Darrell Houghton

MCSE and MOS certified in SharePoint 2013. SharePoint power user, evangelist, and teacher. In-depth knowledge of out-of-the-box SharePoint functionality, best practices, business workflows, and site architecture.

Summit Bundle

Get 200+ hours of Microsoft 365 Training for 27$!

Master Office 365, Power Platform & SharePoint & Teams With 200+ Hours Of Training Videos and 108 Ebooks in the Collab365 Academy. This offer is insane and is only available for a limited period.