4

I created a form that start a workflow automatically when an item is created, and I redirect to html page that shows a message like "Processing... please wait.", and I wait 3 seconds and so redirect to a page with results of the workflow.

Instead of wait 3 seconds, I want to create a javascript that check if the workflow is completed, then redirect to results page.

I am using SharePoint 2010 Foundation

Is there way?

2
  • Please add the version of SharePoint (2007,2010,2013) as a tag to your question. Commented Jul 17, 2013 at 19:37
  • @VardhamanDeshpande ok. I added the tags. It is SharePoint 2010 Foundation. Commented Jul 17, 2013 at 19:39

2 Answers 2

6

I haven't tried this method, but I think it should work. If you use the Lists web service to query for the particular item, you should be able to retrieve the workflow status column and see it's value. It should give you In Progress/Complete. In your code, you'd just need to check that status and wait/recheck in a few seconds or redirect to your page based on the results.

Edit: I tried using SPServices and it does work:

$().SPServices({
    operation: "GetListItems",
    async: false,
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='WFColumn' /></ViewFields>",
    listName: "MyList",
    completefunc: function (xData, Status) {
        $(xData.responseXML).SPFilterNode("z:row").each(function() {
            if ($(this).attr("ows_WFCol" === 5)){
                console.log("It's complete");
          }
        });
    }
});
2
  • worked like a charm! I love SPServices! How I lived all this time without it???? Thanks! Commented Jul 19, 2013 at 15:26
  • Can I get/extract the value of Comments field that's residing in the InfoPath form,[ SP default approval form] with the help of spservices? my requirement is to know, why the default SP 2010 approval workflow was approved, and why the workflow was rejected. ( to extract the reasons for approval/ rejection etc,. )
    – samolpp2
    Commented Apr 24, 2018 at 9:10
0

You can use the Dom/debug in the browser(press F12) then find the 'name =" "' atribute of the column. Then use that name with Spservcies. For my example I trigger my wf by updating a column then returning a workflow status colmn value:

 function CopyStrategyDocuments(StrategyDocID, StrategyDocLocation){



                                $().SPServices({
                                        operation: 'UpdateListItems',
                                        listName: 'Case Attachments',
                                        ID: StrategyDocID,
                                        valuepairs: [['Copy_x002d_Document','Yes'],['Copy_x002d_To',StrategyDocLocation]],
                                                                        completefunc: function(xData, Status) {


                                              var test = $(xData.responseXML).SPFilterNode("z:row").attr("ows_CopyDocu");
                                               alert(test)
                                        //  

                                        }
                                });





      };

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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