5

I am trying to query the user profile service in a SharePoint 2013 workflow to retrive some properties. I am getting a valid response but unable to parse the json into workflow variables.

I am using httpsend to issue a GET call to url

http://<site>/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)/UserProfileProperties?@v='Domain\UserName'

I am getting back a valid response, which looks like below

{
   "d":
   {
       "UserProfileProperties":
       {
           "results":
           [
..............
               ,{
                   "__metadata":
                   {
                       "type": "SP.KeyValue"
                   },
                   "Key": "AccountName",
                   "Value": "Domain\UserName",
                   "ValueType": "Edm.String"
               },
               {
                   "__metadata":
                   {
                       "type": "SP.KeyValue"
                   },
                   "Key": "FirstName",
                   "Value": "UsersFirstName",
                   "ValueType": "Edm.String"
               },
......
          ]
        }
   }
}

Now I am trying to extract values like firstname, manager properties. I used the GetDynmaicValueProperties and stored the value of d/UserProfileProperties into another dynamicvalue variable. I then tried to look on that variable to extract necessary information, but does not seem to be working.

When I loop on d/UserProfileProperties/results, I get each item as

{"__metadata":{"type":"SP.KeyValue"},"Key":"FirstName","Value":"UserFirstName","ValueType":"Edm.String"}

How do I extract values from the json array structure (shown above).

1
  • Did you manage to solve this issue? How do you loop trough results. Is it with foreach activity
    – malibeg
    Commented Apr 8, 2015 at 12:10

3 Answers 3

1

GetDynmaicValueProperties in thePropertyName` you should use

d/UserProfileProperties/results/(0)/Value

More on this topic http://www.andrewconnell.com/blog/SP2013-Workflow-Dynamic-Values

3
  • Amal, that works when I know the index in the array. How do I extract value, when I do not know the index.
    – sssreddy
    Commented Nov 17, 2014 at 16:19
  • Use d/UserProfileProperties in Get item from a dictionary action link Commented Nov 17, 2014 at 16:25
  • I get an error that "Cannot implicity convert value of type dynamic value to dictionary". Also I am using visual studio 2013
    – sssreddy
    Commented Nov 17, 2014 at 16:42
0

You can loop through all the user profile properties and get the required property value.

The workflow stage should be as follows enter image description here

0

You need to use a 'get from dictionary' instead of just setting a variable equal to a literal. This works on SharePoint Online.

this works for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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