2

I have a list in sharepoint. One column is a choice box for pending, approved, denied. I need to create a method to approve all on the click of a button. I cant figure out how because it doesnt represent to the browser itself as a choice box. Its all in a table inside the cell. See the code below.

<div id="jsgrid_combobox" class="combobox-placeholder" style="position:absolute; visibility: inherit; border: 0px; top: 33px; left: 64px; direction: ltr; min-width: 115px; width: 115px; height: 29px; background-color: transparent;"><input type="text" class="cb-textbox " dir="ltr" style="height: 25px; width: 82px;"><input type="button" class="combobox-img" value="▼" tabindex="-1" title="Dropdown" dir="ltr" style="height: 29px;"><div class="combobox-dropdown" style="visibility: hidden; z-index: 0; max-width: 200px; margin-left: 0px; top: 1px; display: none;"><div class="combobox-tablewrapper" style="height: 100px;"><table cellspacing="0" cellpadding="0" class="combobox-panel-table"><tbody><tr class="cb-dp-rw"><td><div></div></td><td style="border-right-width: 0px;"><div class="cb-dp-rw-selected"><div style="white-space: nowrap; padding: 4px;"><span title="Pending" class="jsgrid-control-text">Pending</span></div></div></td></tr><tr class="cb-dp-rw"><td><div></div></td><td style="border-right-width: 0px;"><div class=""><div style="white-space: nowrap; padding: 4px;"><span title="Approved" class="jsgrid-control-text">Approved</span></div></div></td></tr><tr class="cb-dp-rw"><td><div></div></td><td style="border-right-width: 0px;"><div><div style="white-space: nowrap; padding: 4px;"><span title="Rejected" class="jsgrid-control-text">Rejected</span></div></div></td></tr><tr class="cb-dp-rw"><td><div></div></td><td style="border-right-width: 0px;"><div><div style="white-space: nowrap; padding: 4px;"><span title="Additional Info Needed" class="jsgrid-control-text">Additional Info Needed</span></div></div></td></tr></tbody></table></div><a href="#" dir="ltr" class="combobox-link">Edit List Items</a></div></div>

List URL: Expense%20Reports%20v2/Manager.aspx#InplviewHash5fa282cd-555d-4129-9b53- 726afb8b5ac8=ShowInGrid%3DTrue

so i would get for a name of the list of "Expense Reports v2" if i am doing it correctly. I am assuming i can ignore all the other stuff after like the /Manager.aspx etc.

Below is the code i am trying to use as directed, but its not working. All the variables remain undefined throughout its execution.

$().SPServices.SPUpdateMultipleListItems({
    listName: "Expense Reports v2",
    CAMLQuery: "<Query><OrderBy><FieldRef Name='Approval_' /></OrderBy</Query>",
    batchCmd: "Update",
    valuepairs: [["Approval_x0020_Status", "Approved"]]
    });
2

1 Answer 1

1

You can use SpServices and use SPUpdateMultipleListItems() to change the column value to approve for all the items or some specific items based on your query. It would be something like this below:

<script language="javascript" src="/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script><script language="javascript" src="/Scripts/jquery.SPServices-0.7.2.min.js" type="text/javascript"></script><script language="javascript" type="text/javascript">
function ApproveALL()
{
    $().SPServices.SPUpdateMultipleListItems({
                   listName: “Expense Reports v2”,
                   CAMLQuery: "<Query><OrderBy><FieldRef Name='ID' /></OrderBy></Query>", //You can write more specific query
                   valuepairs: [["Approval_x0020_Status", "Approved"]],
                   completefunc: function (xData, Status) {
        alert("Completed");
    }
     });
}
</script>
<button onclick="ApproveALL()">Click me</button>

You can wrap the above in a function and call it on button click.

SpServices

13
  • Ok, so i put this code into a function that i am calling on button click. However, my code never executes and i cant figure out where im going wrong. I have tried to use multiple values for listname and valuepairs for the column name but nothing works. The error i get in the debugger is: Unable to get property 'SPUpdateMultipleListItems' of undefined or null reference It is almost as if its not referenceing the call to the SPservice. Is there any way that i may not have referenced a js file?
    – user519670
    Commented Jul 15, 2015 at 14:20
  • did you refer the spservices jquery file?
    – Taran Goel
    Commented Jul 15, 2015 at 14:31
  • I dont think i have, and that is probably the problem
    – user519670
    Commented Jul 15, 2015 at 14:37
  • Ok, so no i have a reference to both <script type="text/javascript" src="sandbox.expresslocations.com/operations/jsfiles/…> <script type="text/javascript" src="sandbox.expresslocations.com/operations/jsfiles/…> And i have made it a bit farther, now when i am watching the code in the debugger it is at least executing without error, but its not working. It seems as though it cant find info or something because none of the variables, i.e. listName:, CAMLQuery, all say undefined at each step.
    – user519670
    Commented Jul 15, 2015 at 14:52
  • Refer jquery file too. Then please try some different key value pairs too.
    – Taran Goel
    Commented Jul 15, 2015 at 14:54

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.