2

I am trying to run a workflow using JSOM for office365 workflow

I have used this cod to call the function :

<a href="javascript:startWorkflow(\'{FF71E26B-04B8-42CF-B641-30819F122C25}\', '19')">Request for update</a></li>

and for the java script :

function startWorkflow(itemID, subID) {

                        var context = SP.ClientContext.get_current();
                        var web = context.get_web();

                        var wfServiceManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, web);

                        var subscription = wfServiceManager.getWorkflowSubscriptionService().getSubscription(subID);

                        context.load(subscription);

                        context.executeQueryAsync(
                            function (sender, args) {
                                console.log("Subscription load success. Attempting to start workflow.");
                                //notify_i('Request failed', 'Subscription load success. Attempting to start workflow.' + '\n' + args.get_stackTrace());
                                var inputParameters = {};

                                wfServiceManager.getWorkflowInstanceService().startWorkflowOnListItem(subscription, itemID, inputParameters);

                                context.executeQueryAsync(
                                    function (sender, args) { console.log("Successfully starting workflow."); },
                                    function (sender, args) {
                                        console.log("Failed to start workflow.");
                                        console.log("Error: " + args.get_message() + "\n" + args.get_stackTrace());
                                    }
                                );
                            },
                            function (sender, args) {
                                console.log("Failed to load subscription.");
                                console.log("Error: " + args.get_message() + "\n" + args.get_stackTrace());
                            }
                        );
                    }

I am getting this error message:

Subscription load success. Attempting to start workflow. OpenSubjects.aspx:806 Failed to start workflow. OpenSubjects.aspx:807 Error: Value cannot be null. Parameter name: subscription undefined

4

You seem to pass 3 parameters to you method, that only expects 2, and seem to have mixed up the order of them.

function startWorkflow(itemID, subID)

So you should first pass the itemID, the integet of the list item

And then the subscription id, the GUID of the workflow subscription.

  • yes , you are right the issues now changed :) – HAJJAJ Mar 28 '17 at 8:08

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.