I found myself in an unfortunate position of being unable to use SharePoint Designer to build workflows and thus am having to rebuild an approval workflow in JavaScript. I am using REST to insert a new task item but need to expand it to assign the task to all users in a group and make it so that whoever in the group is the first to approve or reject the task will set the task status.
Do I simply need to replace the userId in AssignedToId: userId with groupId? Or would I use the REST API to GET a list of users (and their IDs) from the group name using url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups/getbyname('" + strSPGroupName + "')/users" and then create an array of the user ids for use in this:
data: JSON.stringify({
__metadata: { "type": "SP.Data.TasksListItem" },
Title: "Sample Task",
AssignedToId: { 'results': [11,22] },
DueDate: due,
Status: "In Progress"
})
I have my Task list AssignedTo column set to Allow Multiple Selections: Yes and Allow Selection Of: People and Groups