Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to build a document approval workflow for a sharepoint document library. The workflow needs to be exactly like the OOTB approval workflow with the exception that the Approvers depend on a metadata field in the document. for Example, HR documents needs to be approved by approver1 but finance documents need to be approved by approver2.

I made a copy of the OOTB approval workflow and want to customize it by adding an action to set the value of the Approvers Parameter as shown here (In the real workflow i will add a condition to set the actual value of the parameter but for now I just need to make sure this approach is working).

enter image description here

I set up the value of the Approvers Parameter as:

<d:Approvers xmlns:d="http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields"
       xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls">
  <d:Assignment>
    <d:Assignee>      
      <pc:Person>
        <pc:DisplayName>Approver1</pc:DisplayName>
        <pc:AccountId>DEMO\approver1</pc:AccountId>
        <pc:AccountType>User</pc:AccountType>
      </pc:Person>
    </d:Assignee>
    <d:Stage xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
    <d:AssignmentType>Serial</d:AssignmentType>
  </d:Assignment>
</d:Approvers>

I keep getting the following error in the SP Logs:

    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> 
  System.NullReferenceException: Object reference not set to an instance of an object.     
  at Microsoft.Office.Workflow.Actions.StageContainer.UpdateFromString(SPWeb web, SPItemKey itemId, String assignmentString)     
  at Microsoft.Office.Workflow.Actions.OfficeTask.get_ParticipantList()     --- End of inner exception stack trace ---     
  at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)     
  at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)     
  at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)     
  at System.Workflow.ComponentModel.ActivityBindPropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)     
  at System.Reflection.PropertyInfo.GetValue(Object obj, Object[] index)     
  at System.Workflow.ComponentModel.MemberBind.<>c__DisplayClass1.<GetValue>b__0(Object sender, PathMemberInfoEventArgs eventArgs)     
  at System.Workflow.ComponentModel.PathWalker.TryWalkPropertyPath(Type rootType, String path)     
  at System.Workflow.ComponentModel.MemberBind.GetValue(MemberInfo memberInfo, Object dataContext, String path)     
  at System.Workflow.ComponentModel.ActivityBind.GetMemberValue(Object dataSourceObject, MemberInfo memberInfo, String path, Type targetType)     
  at System.Workflow.ComponentModel.ActivityBind.InternalGetRuntimeValue(Activity activity, Type targetType)     
  at System.Workflow.ComponentModel.DependencyObject.GetBoundValue(ActivityBind bind, Type targetType)     
  at System.Workflow.ComponentModel.DependencyObject.GetValueCommon(DependencyProperty dependencyProperty, PropertyMetadata metadata)     
  at Microsoft.SharePoint.WorkflowActions.CoerceActivity.get_Value()     
  at Microsoft.SharePoint.WorkflowActions.CoerceActivity.Coerce()     
  at Microsoft.SharePoint.WorkflowActions.CoerceActivity.Execute(ActivityExecutionContext provider)     
  at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)     
  at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)     
  at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)     
  at System.Workflow.Runtime.Scheduler.Run()    49157206-76a1-4fe0-8b74-0567086a80ff

Any idea what might be wrong?

Environment: Windows 2008 R2,SP2010 Enterprise edition.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I configured a dynamic approver by changing the "with [these users]" settings into looking up the data from the current item, as shown in step 11 here: http://roykimsharepoint.wordpress.com/2011/02/15/sharepoint-designer-walkthrough-copy-modify-publishing-workflow/

custom approval task assigment from item metadata user/group field

This blogpost suggests that you need to wrap the assignement XML inside an "Assignments" element when used inside a workflow: http://blog.symprogress.com/2011/10/sharepoint-2010-dynamic-approvers-for-oob-approval-workflow-part-2/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.