3

I am attempting to write a SharePoint workflow for an Office 365 site that will operate on “families” of parent tasks and subtasks. I have a parent task and subtasks that look like this:

Parent Task and Subtasks I created a view in SharePoint Designer that displays the Parent ID field. I am attempting to use the new Call HTTP Service workflow action to access the Parent ID: ..site address/_api/web/lists/GetByTitle(ListName)/items?select=Id,Title,ParentID

I get the following results:

Result Set Notice the Item ID and the Item Title fields are correct, but the Parent ID is always 0. I’ve tried any number of variations on the workflow action that I found in various blog posts but none have helped. Can anyone shed any light on what I am doing wrong? Thank you!

2

It seems ParentID is a lookup field. You can check validate it using the List Setting. Then use the expand query as below

siteurl/_api/web/lists/GetByTitle(ListName)/items?$select=Id,Title,ParentID/Id&$expand=ParentID
  • Adding the expand clause causes the whole thing to fail. I now get 0 items returned. I've seen references to that "expand" clause, but no explanation as to what it does. Have tried it before. Btw, the ParentID is not a lookup. It is a column in the list itself. You can expose it in a view created in SharePoint Designer. Just manually add a reference to ParentID in the field list. That's what I did in the first screen shot in my original post. Thanks for your help! – Peter Brase Aug 29 '16 at 13:28
2

I had a similar problem with trying to find the parent ID of a specific field in a 2013 workflow

I solved mine in the following way (although for me I wanted to know the parent ID of the field I was running the workflow on so was also filtering)

siteurl/_api/web/lists/GetByTitle('ListName')/items?$select=Id,Title,ParentID/ID&$expand=ParentID&$filter=ID eq '[%CurrentItem:ID%]'

The trick was when trying to extract the ParentID to use

Get ParentID/ID

this finally returned the parent ID of the item I was running my workflow on. enter image description here

The snapshot above occurs after using a "Call" action in a previous workflow step, which retrieves information from an HTTP Web Service. If you are new to working with Web Services in SharePoint 2013 Workflows using SharePoint Designer 2013, the following site can be referenced as a guide: link

If your workflow is limited in scope to a single Task List, one could consider using the "getbyid" which calls that list by its GUID. E.g.,

https:// <Top level Site URL> /_api/web/lists/getbyid(' <List GUID with Dashes in apostrophes> ')/items?$select=Id,Title,ParentID/ID&$expand=ParentID&$filter=ID eq '[%Variable: currentItem%]'

Finally, just a quick bit of additional context related to the formatting of the $select= portion of our query. ParentID is follwed by a "/" and "ID" because the ParentID field is actually a lookup field containing another item ID from our task list. The $expand= portion of our query further handles this Lookup Field behavior. See here for additional context.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.