I hope I explain this correctly, it's a bit complicated.
So I have this list, where my agents can submit a request to leave work early. They fill out an infopath form and it puts them on the list, which is set so that they can only see their own submission. I have other Managers that have approval permissions to the list who can approve the request. This list has a workflow that will automatically send an email to the agent advising them of the status of their request.

Now, here is the kicker, I've created an HTML page (called MiniList) that uses the SPServices to GetListItems. The purpose of this HTML page is so that my managers can open it and leave it on their screen to monitor during their shift.

$(document).ready(function() {

    operation: "GetListItems",
    async: false,
    listName: "VTO",
    CAMLViewFields: "<ViewFields><FieldRef Name='RequestBy' /><FieldRef Name='Display' /><FieldRef Name='URL' /></ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).find("z\\:row, row").each(function() {
        var liHtml = "<a href='http://requestlist/Lists/VTO1/AllItems.aspx' target='_blank'><li>" + $(this).attr("ows_RequestBy") + " - " + $(this).attr("ows_Display") + "</li></a>";

Then I just have a <div><ul id="tasksUL"/></div> on my HTML page to display each SharePoint item on my page.

What I want to do is create a button next to each item on the HTML page, so that my managers can click the button to approve or reject the request directly on the HTML page, then it will update the list item. Currently the code above, you can see the <a href=...> section is just a link to the list itself, so you can click on each item but they all open just the list.

Another option if you can think of is a way to open the SharePoint item window, I can't find the link to open that form either.

  • Are you using a Workflow for the approval? Or are you just updating a Choice field or something? e.g. When the request is added the field says "Pending" and after the manager approves it, it is changed to "Approved". – Ray Hogan Mar 30 '16 at 10:49
  • That's right, sorry. The workflow is only after the manager approves it. They have to click on the Approve/Reject button on the ribbon. But of course the button is disabled until you select an item. I'm trying to add an approve button and a reject button next to each <li > so that it changes the status for that item. – Chester Mar 30 '16 at 17:50
  • One approach would be to have the id of the list item somewhere (maybe on the button itself). When you click the button you can do a rest query to the list item and update a column with some value. You workflow could then check the status of this column on item update and proceed according to the value. – MickB Aug 7 '17 at 16:46

I am assuming you are referring to the Default SharePoint popup window.

Calling the following function should give what you want:

<script type="text/javascript">
    function clicky(link)
    //useage examples

Note: OpenPopUpPage() is a SharePoint function and shouldn't require you to include an extra js script.

I would advice binding a function to the onclick for example:

<script type="text/javascript">
    elements = document.getElementsByClassName("myLink");
    for (var i = 0; i < elements.length; i++) {
        elements[i].onclick = function (e) {
|improve this answer|||||
  • Hello Raoul, you are correct, I was referring to the SharePoint module for the edit item window. Preferably, I would like to have the Approve & Reject buttons next to each list item within the DIV, but if nothing else just a link to open the item window. I was reading somewhere that you can use the GetListItems CAML script to also get the item's URL as an example: <FieldRef Name="URL"> then use the "ows_URL" as the link. – Chester Mar 31 '16 at 3:57
  • @Chester I would not advice useing JavaScript to connect with Workflows. For what i have seen is that you require a specific Version of SharePoint and workflow. My Company for example won't be able to do this because of Versions and plugins. – Raoul Mensink Mar 31 '16 at 13:04

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.