none
SPD Call HTTP Rest Service: Loop through multivalue Person/Group field

    Question

  • Question:

    1) How to set up a REST/HTTP call in SharePoint Designer so you can loop through Multi-Value Person field and do something for each reference found?

    2)Is it possible to use said reference (f.e. store it an SPD variable) and use that variable when creating a new list entry?

    What I'm trying to do:

    I'd like to make a REST-call and get all Groups mentioned in a Person/Group multi-value field of a single List entry. The Persons/Groups will then asumeably be stored in a dictionary. Then for each Person/Group in the dictionary, I'd like to create a new entry in a seperate list, and assign it to said Person/Group (so no more multi-value field).

    What is/isnt working

    I can set up a REST call that queues for a set of items and do an action for each item, so the SPD code and loop seem to work.

    But, the moment I create the REST call that requests the field values of the multi-value Person field, the set of results seems empty (in the picture below, int_RESToutputcount is 0). But if I look at the XML returned manually, the information is definitially there, so my best guess is that the feed returned is slightly different for some reason and thus I need to change my SPD 'code' respectively.

    Why I'm trying to do this:

    First off, unfortunately I'm bounded to using SPD, Infopath and the web UI. No server access, no custom code.

    What I have: - Custom list (Productieschema): Taskname, Start Date, Due Date

    • Task list (Task List): Lookup:list1(id), Person, Description, Completed

    The idea is that 1 task has to be completed by multiple Groups (any of the participant can mark it complete). They have to be able to add commentary+an attachment. The groups shouldn't be able to see/edit each other's items (without going out of there way).

    Each task would be assigned to 3-10 groups, meaning for each task, you'd have to enter 1 entry in list 1 and 3-10 entries in list 2. This means a lot of manual work as we have around 100 tasks. These tasks also come back roughly each year.

    My solution would be to create a list 0. In this list we have all the fields of List 1 + a multi-value Person field. Then I'd like to create a workflow that 1) Creates an entry in list 1 2) Creates an entry for each Person/Group mentioned, and set its LookupId to the Id in list 1

    Other alternatives

    I have thought of using 'start a task process' and not bother with splitting up the tasks, but we want to have a 'monitor page' that allows us to see exactly which tasks are completed and which aren't. Also, each person has to be able to enter some reasoning, assign a status and add an attachment. Also, they should not see each others' tasks. AFAIK the 'start a task process' option doesn't allow for these requirements

    Attachments

    URL it works with (queues for all items, used to test my loop, it works but its useless of course) <site>/_vti_bin/client.svc/web/lists/getbyid(guid'894750BE-5D64-46DD-AC70-7AACB7906F0D')/Items

    URL it doesn't work with and I don't understand why (queues for the 'assigned to' field of entry with )

    <site>/_vti_bin/client.svc/web/lists/getbyid(guid'894750BE-5D64-46DD-AC70-7AACB7906F0D')/Items(<id>)?$select=AssignedTo/Name,AssignedTo/ID&$expand=AssignedTo/Name,AssignedTo/ID
    

    The XML I get with the last webcall

    <?xml version="1.0" encoding="utf-8"?><entry xml:base="https://sharepoint.utwente.nl/Team/FEZ/Planning_Control/_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" m:etag="&quot;6&quot;"><id>Web/Lists(guid'894750be-5d64-46dd-ac70-7aacb7906f0d')/Items(13)</id><category term="SP.Data.Task_x005f_OverviewListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" href="Web/Lists(guid'894750be-5d64-46dd-ac70-7aacb7906f0d')/Items(13)" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/AssignedTo" type="application/atom+xml;type=feed" title="AssignedTo" href="Web/Lists(guid'894750be-5d64-46dd-ac70-7aacb7906f0d')/Items(13)/AssignedTo"><m:inline><feed><id>96fc4741-c4e7-45ed-be11-e877a071451e</id><title /><updated>2017-02-24T15:57:02Z</updated><entry><id>efcec82b-c0a3-42dc-aff5-9e26ac6be8f6</id><category term="SP.Data.UserInfoItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><title /><updated>2017-02-24T15:57:02Z</updated><author><name /></author><content type="application/xml"><m:properties><d:Name>FEZ Planning &amp; Control monitor (CES)</d:Name><d:ID m:type="Edm.Int32">38</d:ID></m:properties></content></entry><entry><id>b2fa7303-3dbc-4d0a-8df2-fedd226a44a9</id><category term="SP.Data.UserInfoItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><title /><updated>2017-02-24T15:57:02Z</updated><author><name /></author><content type="application/xml"><m:properties><d:Name>FEZ Planning &amp; Control monitor (FA)</d:Name><d:ID m:type="Edm.Int32">41</d:ID></m:properties></content></entry></feed></m:inline></link><title /><updated>2017-02-24T15:57:02Z</updated><author><name /></author><content type="application/xml" /></entry>
    

    (This specific entry has 2 Groups assigned which I want to use, namely:)

    <d:Name>FEZ
     Planning &amp; Control monitor (CES)</d:Name><d:ID m:type="Edm.Int32">38</d:ID>

    and

    <d:Name>FEZ Planning &amp; Control monitor (FA)</d:Name><d:ID m:type="Edm.Int32">41</d:ID>
    

    My SPD workflow looks as follows: (note: it should create 1 item in List Productieschema, and 1 item for each Person/Group resulted from the rest call)


    signature



    • Edited by lmartinl Wednesday, March 1, 2017 3:17 PM xml tags
    Wednesday, March 1, 2017 3:12 PM

All replies

  • Hi lmartinl,

    From your description,  please add “Build Dictionary” action before “Call HTTP web service”action, and add “Content-Type” and “Accept” items to the Dictionary. Then change the “RequestHeaders” property of “Call HTTP web service” to “variable: dictionary”.

    By default response from SharePoint REST is in XML and the SharePoint designer workflow is not able to parse the XML and needs a JSON response. So we need to add “Build dictionary” action.

    Here is a similar post for your reference:

    https://social.technet.microsoft.com/Forums/en-US/a8a890b5-f5fb-447f-b96f-9f3abdb7e178/forum-faq-sharepoint-2013-extracting-values-from-a-multivalue-enabled-lookup-column-and-merge?forum=sharepointgeneral

    Best regards,

    Grace Wang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, March 3, 2017 7:40 AM
  • Dear Grace Wang,

    Apologies if that wasnt clear, I already did exactly this. I just hid it from the screenshot not to complicate things

    Here is the first part of my workflow (it continues in the one I already added).

    As I said, when I call the url that requests for some items, the whole workflow works flawlessly.

    When I use my HTTP request that queries for the multivalue Person field, the dictionary is empty. (in my workflow, this count is 0:)

     

    But the information is definitially in the XML returned. It just doesn't store it in the Dictionary somehow.

    So I'm confused. My best guesses are that either:

    - The url of my HTTP request needs tuning

    - the XML returned when quering for a Multi-Value Person field is differrent than when queuing for normal items and I need to change something in either the Get d/results or the way I store the information from the responsecontent

    - Sharepoint Designer is not capable of this


    signature

    Friday, March 3, 2017 9:11 AM