2

I have a workflow on a list that starts a task process that requires users to Approve/Reject the item. Some of the users do a lot of these approvals each day, and would like a way to mass approve/reject the items. Ok, so on the tasks page, if you mark them as complete, it will treat them as whatever the default is. Except that the user wants the ability to do both. Ok, you can install a code component to add a mass approval/rejection button to the page. Except that the user wants to have the ability to do it from the list of X.

My first idea is to write a component similar to the one for the task page that will allow you to approve a list item, and then go find the associated tasks that the user is waiting on and approve those. I think it will work, but is there another/a better way?

2
  • 1
    Can you clarify this: " Except that the user wants to have the ability to do it from the list of X." Oct 7, 2014 at 10:19
  • 1
    You have a list of items. You have a list of tasks. Ability to approve the tasks from the list of items.
    – Kyle W
    Oct 7, 2014 at 14:26

3 Answers 3

0

You could utilize the jQuery.SPServices wrapper for Workflow.asmx web service and its GetToDosForItem and AlterToDo methods starting from this SPServices story if you need an example of how to call the web service for multiple items.

In short, use SP.ListOperation.Selection.getSelectedItems method to get items marked with checkboxes, then for each item, get the ToDos and alter each ToDo accordingly.

3
  • I don't think the workflow would proceed using this manner. I had the same issue before and had to create my on service hosted within sharepoint. Oct 9, 2014 at 13:20
  • I can't guarantee, but for sharepoint-online it's the option easiest to try for starters. If it fails, we would have to devise a third solution, because neither custom web service nor Workflow.asmx would work. Oct 9, 2014 at 13:37
  • I need to try to mock up his solution tonight when I get a chance. Oct 9, 2014 at 18:16
0

You will need a custom page that will allow them to select the tasks they would like to approved and then you will need to have a service that will do the approvals for you.

You should be able to accomplish this completely using javascript and this service implementation.

 Public Function CompleteExpenseTask(ByVal approvalItemID As Integer, ByVal relatedItemId As Integer) As Boolean

    Using myweb = New SPSite("your site")

        Using subWeb As SPWeb = myweb.OpenWeb()

            Dim approvalList As SPList = subWeb.Lists("your list")

            Dim expenseItem As SPListItem = approvalList.Items.GetItemById(relatedItemId)

            If Not expenseItem Is Nothing Then

                For Each wfTaskItem As Microsoft.SharePoint.Workflow.SPWorkflowTask In expenseItem.Tasks

                    If wfTaskItem.ID = approvalItemID Then

                        Dim ht = New Hashtable

                        subWeb.AllowUnsafeUpdates = True

                        ht(SPBuiltInFieldId.Completed) = "TRUE"

                        ht(SPBuiltInFieldId.PercentComplete) = 1

                        ht(SPBuiltInFieldId.TaskStatus) = SPResource.GetString(New CultureInfo(CType(wfTaskItem.Web.Language, Integer), False), "WorkflowTaskStatusComplete", New Object() {})

                        ht(SPBuiltInFieldId.FormData) = Microsoft.SharePoint.Workflow.SPWorkflowStatus.Completed

                        Microsoft.SharePoint.Workflow.SPWorkflowTask.AlterTask(wfTaskItem, ht, True)

                        'wfTaskItem(SPBuiltInFieldId.WorkflowVersion) = 1

                        wfTaskItem.Web.Update()

                        Return True

                    End If

                Next

            End If

            Return False

        End Using

    End Using

End Function

You can actually accomplish this using the SharePoint Service Application Framework

http://msdn.microsoft.com/en-us/library/office/ee536263(v=office.15).aspx

8
  • Hosting such a service would require a provider hosted app. Oct 9, 2014 at 10:03
  • Not necessarily you could publish the service with the other services available with SharePoint unless he is using SharePoint on Office 365 Oct 9, 2014 at 13:18
  • According to the tags, sharepoint-online is the case Oct 9, 2014 at 13:33
  • By the way, provider hosted app wouldn't have access to Server OM. Oct 9, 2014 at 13:36
  • So you can't publish farm solutions using SharePoint-Online Oct 9, 2014 at 13:49
0

What I ended up going with is javascript hosted on the page that queries the Workflow Tasks for all tasks for the loaded list assigned to the person in question (or a group they are in). Create buttons in each row that has a task (and hide the other rows since I couldn't easily find a way to filter to only rows that have a task associated with them), and have the buttons update the task item.

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.