1

I'm trying to update a list item in a remote sharepoint site using the rest api from a workflow. I'm having issues understanding how to populate a person field. I've looked online and read that you should use the id of the user and not the login, however what if I do not know the users id? Where can I get this from?

I've been reading the following link but it doesn't explain where the id comes from

how to add user to sharepoint list item user field using REST api in sp2013?

pgSystemTester
  • 8,979
  • 2
  • 23
  • 49
Richard Banks
  • 2,946
  • 5
  • 34
  • 71
  • Are you working with javascript or c#? Maybe this helps: [Get User Info via Rest](http://www.vrdmn.com/2013/07/sharepoint-2013-get-userprofile.html) – Nils Aug 27 '15 at 10:59

2 Answers2

0

You will be able to view all UserProfile Properties by using this REST call:

http://siteurl/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='domain\user'

To get a specific Property (in this case UserProfileGUID) use:

http://siteurl/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='UserProfile_GUID')?@v='domain\user'

If you are using CSOM this might help you: The proper way to write a SharePoint User to a User Field in a SharePoint list

I have done this successfully in the past using both CSOM (js) and SSOM (powershell).

Community
  • 1
  • 1
Nils
  • 879
  • 1
  • 9
  • 19
0

I know its a a bit late but for anyone looking for the answer on how to get the user id use the below function

function getUserId(userName) {

    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/siteusers?$select=Id&$filter=Title eq '" + userName + "'",
        type: 'GET',
        headers: {
            "Accept": "application/json;odata=verbose"
        },
        success: function (data) {
            return data.d.results[0].Id;
        },
        error: function (error) {
            console.log(error);
        }
    });
}
Kurt Van den Branden
  • 11,995
  • 10
  • 76
  • 85
SiD
  • 1
  • 4