quinta-feira, 15 de março de 2012

AllowUnsafeUpdates + Workflow = Disaster

Having worked on numerous occasions with custom permissions - adding, removing ... - i've used the SPWeb.AllowUnsafeUpdates property extensively to avoid the "security validation exception, go back" thing. Recently, i had the need to once more deal with custom permissions but for the first time within workflows. So, right away i used AllowUnsafeUpdates to prevent getting the "security validation" exception.

I must say i came very close to tear my own scalp off, because despite having used AllowUnsafeUpdates to the best of my ability, i was still getting slapped with that same exception locking workflow instances with "Failed on Start (retrying)" over and over again.

Moral of the story: the AllowUnsafeUpdates is as useful to the SharePoint workflow runtime, like a shotgun in Chuck Norris's hands. So don't use it.

Soundtrack for this finding:
No music here 'though "Highway to Hell" would've been the perfect choice

Required fields and the check in/out mechanism

This probably very, very basic but i only realized it the hard way: having required fields on a document library, causes all new/uploaded files/items to be checked out automatically, even if the "Require Check Out" list setting is not enabled. Aditionally, no workflow instances will start as expected - lock on "Starting" - until those files/items are checked in.

Soundtrack for this finding:
No music here