I had a requirement whereby no users would have access to input into a list in SharePoint, but that my workflow needed to create an item in it. Perfect for using a web service call with a service account I thought!
I created a service account and added the credentials into my workflow constants for the site.
To start with in my workflow I created a build string action to create the XML to pass into the web service call:
Originally I only needed to add text fields in to the list, so I hooked up my web service call as follows:
I ran the workflow and it created the item perfectly. I was super happy with this.
Then the requirement changed (development wouldn't be the same without a spot of scope creep ) - I needed to take the requester from the originating list and pass it to the people picker field of the destination list. Easy I thought. I added my field name into the XML in the build string and ran again. WRONG. it kept failing and I couldn't work out why. I tried everything possible in the people picker value to pass across, but it wouldn't work.
What I didn't know until now is that the XML wanted me to pass the person or group field in this format:
where userID is the local ID of the user being passed in the web service call.
So then I needed to work out how to get the userID to be able to pass my value in the correct format.
What I did is here (but please shout if there is an easier way):
So now I had the output of the web service call for the requester GetUserInfo.
I then used Query XML action to pull out the ID:
So now I had the user ID I could revisit my original build string action and pass the user in the format required.
I have written this here so that I can revisit next time I need to use this. I don't know about you guys but I am always thinking to myself, "I know I have done that before, but where is it!!" so thought this might be an easier option for me!
Please let me know if anyone has taken a different approach for this. I searched this community and google for answers when I was stumped but I couldn't find anything - but you never know if you search the correct terms!
Hope this helps someone, if not I know it will help me in the future!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.