Workflow 2013 - passing array argument

Hi,

I got this simple workflow with composite task that looks like this:

As you can seen nothing fancy. For this workflow I also got a custom initiation form with a simple text box for entering account names. But apparently this is not how you should pass that argument:

wfParams['assignedTo'] = strInputValue.split(";");

I keep getting error when trying to start workflow:

An error occured when starting workflow. Type 'System.Object[]' with data contract name 'ArrayOfanyType:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected.

Is there any other way to pass arrays to workflow?

September 27th, 2013 3:02pm

Hi,
For this issue, I'm trying to involve someone familiar with this topic to further look at it.
Thanks,
Free Windows Admin Tool Kit Click here and download it now
October 3rd, 2013 2:34am

Hi Valdas,

if i may ask, do you have the array of list and array of object in the same scope for your solution?

if yes, most probably its by design, as my colleague did this and he said that only one type can be given to a scope, so for another scope may be not works.

please have a check this article:

http://msdn.microsoft.com/en-us/library/system.servicemodel.serviceknowntypeattribute.aspx

http://code.msdn.microsoft.com/windowsdesktop/Windows-Workflow-fbb467aa

http://msdn.microsoft.com/en-us/library/kfky451c.aspx

http://msdn.microsoft.com/en-us/library/wak0wfyt.aspx

October 3rd, 2013 4:46am

Hi,

My solution consists of simple workflow visible in previous picture and almost unedited custom instantiation form.

Workflow itself does not contain anything else except for what you can seen. I simply created an argument of type Collection<string> which is required for Assigned To property of Composite Task.

There is no custom C# code involved here.

Here is the full StartWorkflow javascript:

function StartWorkflow() {
            var errorMessage = "An error occured when starting the workflow.";
            var subscriptionId = "", itemId = "", redirectUrl = "";

            var urlParams = GetUrlParams();
            if (urlParams) {
                //itemGuid = urlParams["ItemGuid"];
                itemId = urlParams["ID"];
                redirectUrl = urlParams["Source"];
                subscriptionId = urlParams["TemplateID"];
            }

            if (subscriptionId == null || subscriptionId == "") {
                // Cannot load the workflow subscription without a subscriptionId, so workflow cannot be started.
                alert(errorMessage + "  Could not find the workflow subscription id.");
                RedirFromInitForm(redirectUrl);
            }
            else {
                // Set workflow in-arguments/initiation parameters
                var wfParams = new Object();

                var strInputValue = document.getElementById("strInput").value;
                if (strInputValue) {
                    wfParams['assignedTo'] = strInputValue;
                }

                // Get workflow subscription and then start the workflow
                var context = SP.ClientContext.get_current();
                var wfManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, context.get_web());
                var wfDeployService = wfManager.getWorkflowDeploymentService();
                var subscriptionService = wfManager.getWorkflowSubscriptionService();

                context.load(subscriptionService);
                context.executeQueryAsync(

                    function (sender, args) { // Success
                        var subscription = null;
                        // Load the workflow subscription
                        if (subscriptionId)
                            subscription = subscriptionService.getSubscription(subscriptionId);
                        if (subscription) {
                            if (itemId != null && itemId != "") {
                                // Start list workflow
                                wfManager.getWorkflowInstanceService().startWorkflowOnListItem(subscription, itemId, wfParams);
                            }
                            else {
                                // Start site workflow
                                wfManager.getWorkflowInstanceService().startWorkflow(subscription, wfParams);
                            }
                            context.executeQueryAsync(
                                function (sender, args) {
                                    // Success
                                    RedirFromInitForm(redirectUrl);
                                },
                                function (sender, args) {
                                    // Error
                                    alert(errorMessage + "  " + args.get_message());
                                    RedirFromInitForm(redirectUrl);
                                }
                            )
                        }
                        else {
                            // Failed to load the workflow subscription, so workflow cannot be started.
                            alert(errorMessage + "  Could not load the workflow subscription.");
                            RedirFromInitForm(redirectUrl);
                        }
                    },
                    function (sender, args) { // Error
                        alert(errorMessage + "  " + args.get_message());
                        RedirFromInitForm(redirectUrl);
                    }
                )
            }
        }
Free Windows Admin Tool Kit Click here and download it now
October 3rd, 2013 5:55am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics