Search code examples
sharepointsharepoint-2010sharepoint-workflow

What is wrong with this Sharepoint workflow XML?


I am programmatically starting a workflow by calling workflowManager.StartWorkflow and passing it the XML for workflow below. The workflow just errors and fails. The workflow I am using is the OOTB Approval workflow. Is the structure for my XML incorrect?

<?xml version="1.0" encoding="UTF-8"?>
<dfs:myFields xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:dms="http://schemas.microsoft.com/office/2009/documentManagement/types"
xmlns:q="http://schemas.microsoft.com/office/infopath/2009/WSSList/queryFields"
xmlns:d="http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields"
xmlns:ma="http://schemas.microsoft.com/office/2009/metadata/properties/metaAttributes"
xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <dfs:dataFields>
  <d:SharePointListItem_RW>
     <d:Approvers>
        <Assignment>
           <Assignee>
              <pc:Person>
                 <pc:DisplayName>Jia Ji JOnes</pc:DisplayName>
                 <pc:AccountId>ZZZDomain\jjones</pc:AccountId>
                 <pc:AccountType>User</pc:AccountType>
              </pc:Person>
           </Assignee>
           <d:Stage xsi:nil="true" />
           <d:AssignmentType>Parallel</d:AssignmentType>
        </Assignment>
        <Assignment>
           <Assignee>
              <pc:Person>
                 <pc:DisplayName>Matthew Jones</pc:DisplayName>
                 <pc:AccountId>ZZZDomain\mjones</pc:AccountId>
                 <pc:AccountType>User</pc:AccountType>
              </pc:Person>
           </Assignee>
           <d:Stage xsi:nil="true" />
           <d:AssignmentType>Parallel</d:AssignmentType>
        </Assignment>
        <Assignment>
           <Assignee>
              <pc:Person>
                 <pc:DisplayName>Maree H Jones</pc:DisplayName>
                 <pc:AccountId>ZZZDomain\mhjones</pc:AccountId>
                 <pc:AccountType>User</pc:AccountType>
              </pc:Person>
           </Assignee>
           <d:Stage xsi:nil="true" />
           <d:AssignmentType>Parallel</d:AssignmentType>
        </Assignment>
     </d:Approvers>
     <d:ExpandGroups>true</d:ExpandGroups>
     <d:NotificationMessage>A skill rating has been created which requires your approval.</d:NotificationMessage>
     <d:DueDateforAllTasks xsi:nil="true" />
     <d:DurationforSerialTasks>5</d:DurationforSerialTasks>
     <d:DurationUnits>Day</d:DurationUnits>
     <d:CC />
     <d:CancelonRejection>true</d:CancelonRejection>
     <d:CancelonChange>false</d:CancelonChange>
     <d:EnableContentApproval>true</d:EnableContentApproval>
  </d:SharePointListItem_RW>
</dfs:dataFields>
</dfs:myFields>

Solution

  • The XML was invalid for the approval workflow. The correct XML is below.

    <?xml version="1.0" encoding="UTF-8"?>
    <dfs:myFields xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:dms="http://schemas.microsoft.com/office/2009/documentManagement/types" xmlns:q="http://schemas.microsoft.com/office/infopath/2009/WSSList/queryFields" xmlns:d="http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields" xmlns:ma="http://schemas.microsoft.com/office/2009/metadata/properties/metaAttributes" xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <dfs:queryFields />
       <dfs:dataFields>
      <d:SharePointListItem_RW>
         <d:Approvers>
            <Assignment>
               <Assignee>
                  <pc:Person>
                     <pc:DisplayName>Jia Ji JOnes</pc:DisplayName>
                     <pc:AccountId>ZZZDomain\jjones</pc:AccountId>
                     <pc:AccountType>User</pc:AccountType>
                  </pc:Person>
                  <pc:Person>
                     <pc:DisplayName>Matthew Jones</pc:DisplayName>
                     <pc:AccountId>ZZZDomain\mjones</pc:AccountId>
                     <pc:AccountType>User</pc:AccountType>
                  </pc:Person>
               </Assignee>
               <d:Stage xsi:nil="true" />
               <d:AssignmentType>Parallel</d:AssignmentType>
            </Assignment>
         </d:Approvers>
         <d:ExpandGroups>true</d:ExpandGroups>
         <d:NotificationMessage>test</d:NotificationMessage>
         <d:DueDateforAllTasks xsi:nil="true" />
         <d:DurationforSerialTasks>5</d:DurationforSerialTasks>
         <d:DurationUnits>Day</d:DurationUnits>
         <d:CC />
         <d:CancelonRejection>false</d:CancelonRejection>
         <d:CancelonChange>true</d:CancelonChange>
         <d:EnableContentApproval>true</d:EnableContentApproval>
      </d:SharePointListItem_RW>
       </dfs:dataFields>
    </dfs:myFields>