LookUp Activities in Visual studio for SP 2013 Workflows

 

In Visual studio 2012, for SharePoint 2013 Workflows there are list lookup activities available; LookupSPList, LookupSPListItem and so on. These activities work fine when the solution is deployed as Sandboxed solution (Please note that Sandboxed solutions are deprecated in SharePoint 2013) . But when the solution is deployed as Farm solution, it breaks. You will get an error message like this;

System.FormatException: Expected hex 0x in "{0}".
at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID Object failureMessageFormatArgument, String failureArgumentName, Exceptio innerException)
at System.Guid.TryParseGuidWithHexPrefix(String guidString, GuidResult& result)
at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
at System.Guid.Parse(String input)
at Microsoft.Activities.Expressions.ParseGuid.Execute(CodeActivityContext context)
at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

 

 

image

 

The problem happens because of the ListId value that we provide in the workflow designer view. The GUID of the list is not retrieved properly by the workflow when selecting the name from the list of available ListId options. It’s a known issue and the fix for this problem will be available anytime soon.

As a temporary solution you can remove the lookup of the List ID and replace it with a static GUID. Remember this is not a good long term solution as the GUID will change on every deployment. To do this, in the workflow designer when you select the lists, click the ellipse and then in the edit box replace System.Guid.Parse("{$ListId:Lists/MyList;}") with the list GUID System.Guid.Parse("{75DD48E6-44D3-43B1-BD83-D836CDE04FB9}") .  To get the list GUID, go to List settings, copy the URL and then decode the list URL alone using any of the online tools available.