Solve: SharePoint Designer Workflow Not Always Firing using Event Receiver
Introduction/ Question / Hypothesis
So earlier today Marc D. Anderson [http://www.sympmarc.com or @sympmarc] sent out a tweet regarding a SharePoint Designer Workflow not firing and pointed us to a post he added in StackExchange here SharePoint Designer Workflow Not Always Firing so I wont belabor this post with the details, he spells it out quite excellently.
So, a few of us Scott @ciphertxt Hoag, myself, Tasha @tashasev Scott chimed in and offered approaches to solving the problem, notwithstanding the great suggestions, and they were great suggestions, my bias as a SharePoint developer [ignoring that you should seek Out of Box solutions first] commented ad-nausium that it could be handled quite easily with an event receiver, assuming that you were allowed to write code as a solution to the issues faced.
Materials/Methods
Schooled as I am from the British educational system in the commonwealth, I approach everything through a scientific method. So, my approach was going to be
- Create an Environment adhering to the same boundaries as the test case
- Create an Empty SharePoint Solution in Visual Studio 2010
-
Create two Projects
- Project 1: A Console App to Prove out the work
- Project 2: The actual event receiver with the (hopefully) working code
- Test, Re-Test, Brag about it J if it works
Creating the Environment
First thing to do was create an environment for the Managed Metadata Service with my own nomenclature but adhering to the test case
Next we create a list to consume the information
Configure the MMS Column to get data from the Term Set under the MarcDAnderson Group
Creating the Visual Studio Solution
Next we have to create a blank SharePoint Solution in Visual Studio. I do this because I don’t want any of the extraneous things that come with a predefined project as well as, I plan to have a tester project as well as an Event Receiver Project, its easier and cleaner to control that yourself.
You will notice the Tester Project is set as Startup, we will change that for the Event Receiver time to deploy. So, since we will be working with Managed Metadata Service (MMS) you will need reference not only to the standard SharePoint dlls, but also Microsoft.SharePoint.Taxonomy as well, in both your Console App and the actual Event Receiver.
As this was an empty project, when you click on the project and do "New Item" and select Event Receiver, it will add the Microsoft.SharePoint and Microsoft.SharePoint.Security, but you will have to manually add the .Taxonomy
When you have done that, its time to code out the Tester Console App, which is quite simple, and after I was done I realized I could have just gone straight to the Event Receiver because it wasn’t that complicated, in fact, its more lines of code in the tester than there will be in the production deliverable.
Testing out that code yielded the below.
Next I coded out the Event Receiver, since the context of the Item is inside the SPItemEventProperties, no need for a SPSite, SPWeb ect. I just needed an SPListItem object to bind to the Event Properties as in Line 21 and we are off to town. MMS Fields are in value pairs, Label and Guid, so you use the TaxonomyFieldValueCollection to bind to the field holding the MMS value and then split it base on the Pipe [|] character that separates the named values. As you can see on line 27 I have the pair commented out, that is because Marc only needs the Label, as shown in line 28. After that its just setting the Text Columns named "ValueStringFromCategory" with the values from the MMS Field and calling the Update Method.
That’s it, now time to Deploy and Test..
Results
Once deployed, you can just add a new item as you see below
Select the MMS field or fields, I did set mine to multi-value, it wasn’t called out in the Test Case, but I wanted to be complete.
Click OK, leaving out the third field because that WILL be filled out by the Event Receiver. Click Save when done.
You will notice that the field is blank when you click save, but when you refresh the list, as seen below, the item appears. If you did this in the ItemAdding Event of the Event receiver then you would not need to refresh. But i didnt, so…
Discussion/Summary Findings
So, lessons learned. Marc says that this is ok, but doing a Custom Workflow activity would take this to the next level, so will tackle that on the plane ride to #SPS12
Cheers all.. See you in VEGAS!!
November 9, 2012 Posted by fabiangwilliams | Managed Metadata, SharePoint 2010, Visual Studio 2010 | IA, Managed Metadata, SharePoint 2010, Taxonomy | Leave a comment
Blog Stats
- 437,657 hits
Category
- Azure (6)
- Business Connectivity Services (20)
- Client Side Coding (1)
- Content Organizer (1)
- Content Types (2)
- Entity Framework (2)
- Facebook (1)
- Folksonomy (2)
- IIS (2)
- JSON (11)
- Kerberos (2)
- LAMP (1)
- Linux (1)
- Managed Metadata (3)
- Metalogix (1)
- Mobile (1)
- MobileApps (1)
- MVC (1)
- MySites (1)
- OData (2)
- Office 2010 (5)
- Office 2010 Beta (10)
- Office 2010 TP (4)
- Office 365 (9)
- Office Social Connector (1)
- Outlook 2010 (2)
- PhoneGap (1)
- PowerShell (1)
- Public Speaking (9)
- REST (13)
- Secure Store (2)
- Sencha (1)
- SharePoint 2010 (45)
- SharePoint 2010 RTM (9)
- SharePoint 2013 (19)
- SharePoint 2013 Workflows (8)
- SharePoint Administration (35)
- SharePoint Bug (4)
- SharePoint Designer 2010 (6)
- SharePoint Designer 2013 (15)
- SharePoint Development (31)
- SharePoint Error/Resolution (12)
- SharePoint Errors (1)
- SharePoint Friends (1)
- SharePoint General (24)
- SharePoint How-To (61)
- SharePoint Migration (2)
- SharePoint Online (5)
- SharePoint Saturdays (9)
- SharePoint Workspace 2010 (1)
- Site Columns (2)
- Social SharePoint (2)
- SQL Server (9)
- Strange Stuff (7)
- Tags and Ratings (2)
- Talking Technology (1)
- Taxonomy (2)
- Term Store (2)
- Ubuntu (1)
- Uncategorized (6)
- Video Screencast (2)
- Visual Studio 2010 (9)
- Visual Studio 2012 (5)
- Visual Studio 2013 (3)
- WCF (3)
- Webcast (3)
- Where is Fabian (26)
- Windows Administration (2)
- Windows Azure (2)
- Workflows (6)
Search my Blog
Archives
- December 2013 (3)
- November 2013 (3)
- October 2013 (5)
- September 2013 (9)
- July 2013 (2)
- May 2013 (3)
- April 2013 (6)
- December 2012 (1)
- November 2012 (1)
- April 2012 (1)
- February 2011 (1)
- November 2010 (1)
- October 2010 (3)
- September 2010 (4)
- August 2010 (2)
- July 2010 (3)
- June 2010 (3)
- May 2010 (1)
- April 2010 (7)
- March 2010 (5)
- February 2010 (7)
- January 2010 (3)
- December 2009 (7)
- November 2009 (16)
- September 2009 (6)
- August 2009 (6)
- July 2009 (8)
- June 2009 (1)
- May 2009 (1)
- April 2009 (7)
Pick your Poison!
Activity Feed Azure BCS BDC BPR Business Connectivity Service Business Connectivity Services Business Process Content Source Cumulative Updates Document Library Enterprise Search Event ID: 3351 Event ID: 6398 Event ID: 6872 Fabian Fabian Williams Full-Trust Proxy Happy Birthday Fabian IA JSON LINQ LINQ to SharePoint London Loops Managed Metadata Metalogix MOSS 2007 MOSS 2010 MSDN; Workflows; SharePoint; Visual Studio MVC MySite Object Model Office 2010 Public Speaking; Smposium REST Sandbox Solutions Search Scope Secure Store Shared Service Provider SharePoint SharePoint 2010 SharePoint 2013 SharePoint Designer SharePoint Designer;Workflow SharePointFabian SharePoint Workspace Social SP2010 SPD SPEVO13 SPLive360 SPTechCon SSP Stages Taxonomy UserProfile Visual Studio Workflow Workflows Workflows; SharePoint; Visual StudioFabian Tweets – yep i tweet too much!
- Viewing SharePoint Lists from within Microsoft Teams just got cool flip.it/dxCA62...next... 9 hours ago
- So... I was asked today by a few people “how my day is going?” - I’m now responding with this... “Some people choos… twitter.com/i/web/status/9…...next... 1 day ago
- It’s that time again #freezeallmotorfunctions #WestworldSeason2...next... 1 day ago
- Nice work @KbWorks >> #SharePoint Api -> @OfficeDev #Graph -> Microsoft Graph flip.it/ZDtruy...next... 3 days ago
- RT @vesajuvonen: Latest #SharePoint Patterns and Practices (PnP) community call recording from 19th of April. SharePoint Dev and community…...next... 4 days ago
- Shout out to the good folks at @sharegatetools for all their help over last few days! Much appreciated & especially… twitter.com/i/web/status/9…...next... 4 days ago
- So @github launches bot-powered learning lab for budding developers flip.it/pcaRtF...next... 4 days ago
Fabian Williams
SharePoint Architect at Planet Technologies Inc. Solving problems with SharePoint day and night.
..."Quinon Proficit Defecit"Subsribe to my Feeds
Request Me to Speak!
Download Blog Mobile App
Where U At? – Places I be
Event NameDate(s)RoleSharePoint Conference 2014 - Las Vegas 03/03/2014 - 03/06/2014 Speaker SharePoint Saturday - DC-Reston 12/07/2013 Speaker Previous EngagementsTimeframeRoleSharePoint Live - Orlando 11/18/2013 - 11/22/2013 Speaker Dev Connections - Las Vegas 9/30/2013 - 10/4/2013 Speaker SharePoint Saturday Columbus 09/14/2013 Speaker SharePoint Saturday New York City 07/27/2013 Speaker Microsoft TechEd North America 06/03/2013 - 06/06/2013 MS Staff SharePoint Evolutions Conf. - London 04/15/2013-04/18/2013 Speaker SharePoint Saturday - Indianapolis 01/12/2013 Speaker SharePoint Satureday- Virgina Beach 01/05/2013 Speaker CY 2011 & 2012 Various Events On My Old SP2010 Blog Speaker SharePoint Saturday - Ozarks 06/12/2010 Speaker SharePoint Saturday - New York 06/31/2010 Speaker SharePoint Tech Conference - Boston 10/20/2010 Speaker SharePoint Saturday - D.C. 05/15/2010 Speaker SharePoint Saturday - New Orleans 02/27/2010 Speaker SharePoint Saturday Online - Arabia 03/27/2010 Speaker SharePoint Saturday - Charlotte N.C. 04/10/2010 Speaker SharePoint Saturday - Indianapolis 01/30/2010 Speaker SharePoint Tech Conference - San Fran 02/10/2010 - 2/12/2010 Speaker SharePoint Saturday - Virginia Beach 01/9/2010 Speaker SharePoint Saturday - D.C December 2009 Speaker Baltimore SUG November 2009 Speaker SharePoint Saturday - San Antonio November 2009 Speaker SharePoint Conference 2009- Vegas October 2009 Attendee SharePoint Tech Conf - Boston June 2009 Speaker SharePoint Saturday - Baltimore June 2009 Panelist SharePoint Tech Conf - San Fran January 2009 Speaker Top Posts
- Using the Call HTTP Web Service REST Calls in SharePoint Online using SPD
- How To: Create, Configure, Consume SharePoint 2010 Secure Store in Business Connectivity Services
- More on SharePoint 2013 REST API with Fiddler and SPD
- Creating a SharePoint Timer Job using SharePoint Designer 2013
- HELP: Unable to Create List using SharePoint 2013 REST API in SPD2013
Blogs from SharePoint Colleagues