none
Bulk Approval for tasks in SharePoint OOTB Workflow Task list RRS feed

Answers

  • Hi Folks,

    I was able to managed to get the Workflow Task references (Related Content) for the document libraries / custom list that are attached to Workflow task.

    It was bit tricky and but able to solve it. Tools used: Fiddler (it’s a must for developing SharePoint Add-ins client side object model) and SharePoint Manager.  This is the code

    function ShowAllItems() {
        var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
    
        var ctx = SP.ClientContext.get_current();
        var hostContext = new SP.AppContextSite(ctx, hostUrl);
        var web = hostContext.get_web();
        var listWF = web.get_lists().getByTitle("Workflow Tasks");
    
        var query = new SP.CamlQuery();
        var items = listWF.getItems(query)
        query.set_viewXml("<View />")
        ctx.load(web, "Title");
        ctx.load(items, "Include(Id, Title, Status, WorkflowLink, PercentComplete, WorkflowOutcome)");
    
        ctx.executeQueryAsync(success, fail);
    
        function success() {
            var message = jQuery("#message");
            var ienum = items.getEnumerator();
            while (ienum.moveNext()) {
                message.append("<br />");
                message.append(ienum.get_current().get_item("Title")) + message.append(" , ");
                message.append(ienum.get_current().get_item("Status")) + message.append(" , ");
    
    
                if (typeof (ienum.get_current().get_item("WorkflowLink")) != 'undefined' && (ienum.get_current().get_item("WorkflowLink")) != null)
                {
                    message.append(ienum.get_current().get_item("WorkflowLink").get_url()) + message.append(" , ");
                }
                
                message.append(ienum.get_current().get_item("PercentComplete")) + message.append(" , ");
                message.append(ienum.get_current().get_item("WorkflowOutcome")) + message.append(" , ");
                
            }
        }
    
        function fail(sender, args) {
            alert("Call failed. Error: " +
                args.get_message());
        }
    
        
    }



    and the screenshot. 

    I guess it help others who are developing SharePoint apps / Add-ins


    Sandy


    • Edited by Sandy 791 Monday, December 19, 2016 3:22 AM updated the question
    • Marked as answer by Sandy 791 Monday, December 19, 2016 3:23 AM
    Sunday, December 18, 2016 11:33 AM

All replies

  • Hi folks,

    In my case, I have attached two SharePoint libraries for sample workflows

    • Department (a custom list)
    • Shared Documents (Out of the Box SharePoint)

    In SharePoint Manager 2013, I can see  Department (Custom list) >> Properties >> WorkflowAssociations (a collection) >> I am able to see the Workflow Tasks within SPWorkflowAssociation properties.


         
    The same thing applied to Shared Documents >> >> Properties >> WorkflowAssociations (a collection) >> I am able to see the Workflow Tasks within SPWorkflowAssociation properties.



    On the Workflow Task page, I can view the reference document libraries (Department) in a column named “Related Content” that are associated to Workflow task page as shown:



    The  Challenge I am facing is that how could use this “Related Content” column with specific ID that is associated with this workflow task in my SharePoint Add-in code. 

    Related Column is a hidden field and use URL properties. 





    I have to use CSOM or REST to achieve this.  

    Any help would be highly appreciated with sample code, if any. 


    Sandy

    Saturday, December 17, 2016 5:45 PM
  • Hi Folks,

    I was able to managed to get the Workflow Task references (Related Content) for the document libraries / custom list that are attached to Workflow task.

    It was bit tricky and but able to solve it. Tools used: Fiddler (it’s a must for developing SharePoint Add-ins client side object model) and SharePoint Manager.  This is the code

    function ShowAllItems() {
        var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
    
        var ctx = SP.ClientContext.get_current();
        var hostContext = new SP.AppContextSite(ctx, hostUrl);
        var web = hostContext.get_web();
        var listWF = web.get_lists().getByTitle("Workflow Tasks");
    
        var query = new SP.CamlQuery();
        var items = listWF.getItems(query)
        query.set_viewXml("<View />")
        ctx.load(web, "Title");
        ctx.load(items, "Include(Id, Title, Status, WorkflowLink, PercentComplete, WorkflowOutcome)");
    
        ctx.executeQueryAsync(success, fail);
    
        function success() {
            var message = jQuery("#message");
            var ienum = items.getEnumerator();
            while (ienum.moveNext()) {
                message.append("<br />");
                message.append(ienum.get_current().get_item("Title")) + message.append(" , ");
                message.append(ienum.get_current().get_item("Status")) + message.append(" , ");
    
    
                if (typeof (ienum.get_current().get_item("WorkflowLink")) != 'undefined' && (ienum.get_current().get_item("WorkflowLink")) != null)
                {
                    message.append(ienum.get_current().get_item("WorkflowLink").get_url()) + message.append(" , ");
                }
                
                message.append(ienum.get_current().get_item("PercentComplete")) + message.append(" , ");
                message.append(ienum.get_current().get_item("WorkflowOutcome")) + message.append(" , ");
                
            }
        }
    
        function fail(sender, args) {
            alert("Call failed. Error: " +
                args.get_message());
        }
    
        
    }



    and the screenshot. 

    I guess it help others who are developing SharePoint apps / Add-ins


    Sandy


    • Edited by Sandy 791 Monday, December 19, 2016 3:22 AM updated the question
    • Marked as answer by Sandy 791 Monday, December 19, 2016 3:23 AM
    Sunday, December 18, 2016 11:33 AM
  • Hi Sandy,

    Glad to hear that you solve the issue, thanks for your sharing.

    If the original issue has been resolved, it would be appreciated if you can mark the reply as answer, others who stuck with the similar issue would be easier to search for valid solutions in this forum.

    Thanks,               

    Patrick



    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, December 19, 2016 3:02 AM
    Moderator