For the ticketing system I've been working on, a task will be created via workflow whenever a new ticket (discussion) is created, which is assigned to the specific personnel assigned to that particular category of tickets.
Right now, we have a requirement to update the task's details when the original ticket is updated (i.e. when the ticket is "Closed" in the forum, the task will also be marked as completed). In other words, the workflow that triggers on ticket update will have to call the task which is tied to said ticket.
This information appears to be stored within the RelatedItems column within the Tasks list. As an example, running a GET call using the REST API to the following URI -
<site collection>/<site>/_api/web/lists/getbytitle('Tasks')/items?$select=RelatedItems
(Note: 'Accept' and 'Content-Type' set to 'application/json; odata=verbose')
yields the following results for RelatedItems:
{
d: {
results: [1]
0: {
__metadata: {
id: "fd7c1b83-a0e5-4c19-851c-744df77b799c"
uri: "<site collection>/<site>/_api/Web/Lists(guid'6c2b2b63-b64d-46b9-a845-288e6ec8c746')/Items(39)"
etag: ""2""
type: "SP.Data.TasksListItem"
}-
RelatedItems: "[{"ItemId":5,"WebId":"1a6ccde0-95a3-4134-a787-4afb8a437fa5","ListId":"82410f3d-d778-4638-b7c6-f24d89fe84a4"}]"
}
}
}
This means that the task shown has a related item (the ticket (Discussion)) with ID=5, located in the list (category/Discussion Forum) with GUID=82410f3d-d778-4638-b7c6-f24d89fe84a4.
What I am trying to do now in the ticket update workflow is to pass said ticket's ID (and List GUID) as filter values to the Tasks list, which should return the task that was created by the ticket creation workflow for that ticket. However, I have not been able to filter the Tasks lists by RelatedItems using those values (the GET call simply throws an error that "The field 'RelatedItems' of type 'RelatedItems' cannot be used in the query filter expression.").
Is there a way to retrieve the task from the Tasks list based on the ID and List GUID of its related item (ticket)? I realize that one could query the entire Tasks list through the workflow and compare to each task's RelatedItems field until a match is found, but that is likely to be impractical when we have multiple active tickets (and tasks) in the system.
As before, we are mostly restricted to OOTB SharePoint Online 2013 and Sharepoint Designer 2013. Thanks in advance for your advice.