Getting Id of People field

Good Afternoon,

I am having some issues getting the Id of the selected value of a people field, on load of a form my code works fine, but if the people field is changed by a user the code to retrieve the Id no longer works as it appears the Id is no longer part of the EntityData.

My code is

currentlyAssingedToId = fd.field('Assigned_x0020_To').value.EntityData.SPUserID;

And following a user changing the field the object return is a follows: -

Capture

On load the object returned is: -

Capture

The reason I need the Id is because I need to update an item using PnP...

Thanks

Hello @Tony_Duke,

Please use the following code to get the user ID when the PeoplePicker field is changed.

Please replace PeoplePickerField with the internal name of the field.

fd.spRendered(function(){
    fd.field('PeoplePickerField').ready().then(function(field) {
        field.$on('change', function(value) {
            pnp.sp.web.siteUsers.getByLoginName(value.Key).get()
            .then(function(result) {
                console.log(result.Id);
            });
        });
    });
});