Hello everyone.
A simple question: I want to create a REST call to get the last Workflow Task related a specific item.
I created this url odata query:
https://zsis.sharepoint.com/sites/xxxx/_api/web/lists/getbytitle('workflowtasklist')/items?$select=Id,AssignedToId,AssignedTo/FirstName,AssignedTo/LastName,AssignedTo/Name,Created,RelatedItems&$expand=AssignedTo&$orderby=Created desc&$top=1
and I can get this result:
<?xml version="1.0" encoding="utf-8"?><feed xml:base="https://zsis.sharepoint.com/sites/xxxx-TEST04/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"><id>3b98e09d-35d7-471a-b866-da4d9592a5ff</id><title /><updated>2015-07-21T09:17:17Z</updated><entry m:etag=""3""><id>f38328c8-d048-4bee-b7ec-fcd1c85024b2</id><category term="SP.Data.WorkflowTaskListListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" href="Web/Lists(guid'941f4087-0a59-49b4-bf6c-a9f92d51fdd4')/Items(329)" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/AssignedTo" type="application/atom+xml;type=feed" title="AssignedTo" href="Web/Lists(guid'941f4087-0a59-49b4-bf6c-a9f92d51fdd4')/Items(329)/AssignedTo"><m:inline><feed><id>a80851b9-aaa9-4e6e-b5e1-e7d2c6529057</id><title /><updated>2015-07-21T09:17:17Z</updated><entry><id>1e8f3a88-4c86-4b7b-9aa5-35b0ef036c54</id><category term="SP.Data.UserInfoItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><title /><updated>2015-07-21T09:17:17Z</updated><author><name /></author><content type="application/xml"><m:properties><d:FirstName>Mario</d:FirstName><d:LastName>Rossi</d:LastName><d:Name>i:0#.f|membership|mario.rossi@it.zsis.com</d:Name></m:properties></content></entry></feed></m:inline></link><title /><updated>2015-07-21T09:17:17Z</updated><author><name /></author><content type="application/xml"><m:properties><d:Id m:type="Edm.Int32">329</d:Id><d:AssignedToId m:type="Collection(Edm.Int32)"><d:element>19</d:element></d:AssignedToId><d:RelatedItems>[{"ItemId":244,"WebId":"39ba6aaf-4ee4-xxxx-b6b1-xxxxxxxxxxxx","ListId":"bfb72196-81c7-4112-89ac-2c00ce762f03"}]</d:RelatedItems><d:ID m:type="Edm.Int32">329</d:ID><d:Created m:type="Edm.DateTime">2015-06-18T08:18:40Z</d:Created></m:properties></content></entry><link rel="next" href="https://zsis.sharepoint.com/sites/xxxx-TEST04/_api/web/lists/getbytitle('workflowtasklist')/items?%24skiptoken=Paged%3dTRUE%26p_Created%3d20150618%252008%253a18%253a40%26p_ID%3d329&%24select=Id%2cAssignedToId%2cRelatedItems%2fItemId%2cAssignedTo%2fFirstName%2cAssignedTo%2fLastName%2cAssignedTo%2fName%2cCreated&%24expand=AssignedTo&%24orderby=Created+desc&%24top=1&=" /></feed>Now: I have to apply a $filter to the RelatedItems Field, getting only the task related to a specific Id (e.g. ItemId eq 244).
How can I do this?
Thanks,
Sergio
Regards,
Bubu
http://zsvipullo.blogspot.it
Please mark my answer if it helped you, I would greatly appreciate it.