1

So I find myself needing to start a SharePoint 2010 Site workflow on a SharePoint Online site. Since this workflow starts a custom task process, it's been created with an Assignment Stage parameter to provide for the task's AssignedTo field.

Using the Workflow Interop Service, I've managed to start the workflow, but regardless of what I use for the Assignment Stage parameter, the workflow always ends up starting with that parameter blank. The only information I could turn up on Google related to starting a workflow using the Server Object Model. Going that route, the author used the workflow's raw initiation form XML to trigger the workflow with the desired assignment stage. I tried to replicate that process with the CSOM API by using xml similar to the following:

            <d:Assignment>
                <d:Assignee>
                    <pc:Person>
                        <pc:DisplayName>{0}</pc:DisplayName>
                        <pc:AccountId>{1}</pc:AccountId>
                        <pc:AccountType>User</pc:AccountType>
                    </pc:Person>
                </d:Assignee>
                <d:Stage>0</d:Stage>
                <d:AssignmentType>Parallel</d:AssignmentType>
            </d:Assignment>

Unfortunately, however, this also failed to produce the desired results.

0

While I never did find a solution for this using CSOM, I managed to make it work by changing my workflow to a list workflow, then starting it with the Workflow.StartWorkflow SOAP operation. (https://domain.sharepoint.com/_vti_bin/Workflow.asmx?op=StartWorkflow) I found this blog post to be extremely helpful when I was implementing my solution. (A Gist containing the code for the blog post can be found here)

My code ended up too abstracted and lengthy to post, but if someone still needs help, add a comment and I'll try to post a quick reference.


For my workflow, I used the following XML for the workflowParameters parameter of the SOAP operation:

<dfs:myFields xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:dms="http://schemas.microsoft.com/office/2009/documentManagement/types" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" 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>
            ... Other Parameters ...
            <d:AssignmentsParameter>
                <d:Assignment>
                    <d:Assignee>
                        <pc:Person>
                            <pc:DisplayName>{User.Title}</pc:DisplayName>
                            <pc:AccountId>{User.LoginName}</pc:AccountId>
                            <pc:AccountType>User</pc:AccountType>
                        </pc:Person>
                    </d:Assignee>
                    <d:Stage>0</d:Stage>
                    <d:AssignmentType>Parallel</d:AssignmentType>
                </d:Assignment>
            </d:AssignmentsParameter>
        </d:SharePointListItem_RW>
    </dfs:dataFields>
</dfs:myFields>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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