0

The Situation

I have a workflow in a SharePoint 2007 List that require approval. Thus, there is a column called 'Approval Status' generated by SharePoint itself. How do I use SPServices to set the value?

The Code

        function CreateNewItem() {
            $().SPServices({
                operation: "UpdateListItems",
                async: false,
                batchCmd: "New",
                listName: "System A",
                valuepairs: [["Approval_x0020_Status", "Approved"]],
                completefunc: function(xData, Status) {
                   $("#responseStatus").html(Status);
                   $("#responseXML").text(xData.responseXML.xml);

                }
            });
        }

The above code is tested but it cannot change the Approval Status from Pending to Approved.

Update (Using Marc D Anderson Answer)

The full code:

    function CreateNewItem() {
        $().SPServices({
            operation: "UpdateListItems",
            async: false,
            batchCmd: "Moderate",
            listName: "System A",
            valuepairs: [["_ModerationStatus", "0"]],
            completefunc: function(xData, Status) {
               $("#responseStatus").html(Status);
               $("#responseXML").text(xData.responseXML.xml);

            }
        });
    }
  • super man realy very very thankful to who has posted this – user5648 Nov 15 '11 at 9:50
1

Take a look at this thread in the SPServices discussions:

Looks like the answer is to use

 Cmd='Moderate' and ["_ModerationStatus", "0"] to approve
0

This might be old thread but it might be useful, Below is the spservice code to approve

function approveItem(webUrl,listTitle,itemId) {
   $().SPServices({
      webURL : webUrl, 
      operation: "UpdateListItems",
      listName: listTitle,
      ID: itemId,
      batchCmd: "Moderate",
      valuepairs: [["WorkflowOutcome", "Completed"],["Status", "Approved"],["PercentComplete", "1"],["_ModerationStatus", "0"]],
      completefunc: function (xData, Status) 
      {
        console.log(xData.responseXML); 
      }
   });
}

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.