Populate field with current user property doesn't work

Hello!

I try to populate some fields when a field change and it's all ok but when I try to populate a single line text field with current user property nothing happens.

This is my code

function updateCurrentUserInfo() {
pnp.sp.profiles.myProperties.get().then(function(result) {

    var props = result.UserProfileProperties;

    for (var i = 0; i < props.length; i++) {

        switch (props[i].Key) {
            case 'CellPhone':
                fd.field('prova').value = props[i].Value;
                break;
            case 'Title':
                fd.field('JobTitle').value = props[i].Value;
        }
    }
});

}

fd.spRendered(function(){
fd.control('ContraenteLook').$on('change', function(value){
//populate Address field with the Extra field value
fd.field('Nominativo').value = fd.control('ContraenteLook').value.Nominativo;
fd.field('Cellulare').value = fd.control('ContraenteLook').value.Cellulare;
fd.field('Mail').value = fd.control('ContraenteLook').value.Mail;
fd.field('Privacy').value = fd.control('ContraenteLook').value.Privacy;
fd.field('CIPAnagrafica').value = fd.control('ContraenteLook').value.CIPAnagrafica.Title;
updateCurrentUserInfo();
});
});

Hello @Fritz77,

Welcome to the community!
Could you share the output of your browser console when trying to update user info? You should be able to open it with F12.

I get this output on loading

Hi @Fritz77,

The important line in the error log is the one that says Cannot set properties of undefined (setting 'value').

It means that at least one of the fields you're addressing isn't found: likely, you either made a mistake in the name or used an incorrect function (controls should be addressed with control(), and fields with field()).

Please check and let me know about your findings. If the issue persists, export your form and send it to support@plumsail.com

1 Like

My fault, there was an error on "Field" instead "control" BUT, it doesn't work.

Now the error I get is

Hello @Fritz77 , it is not related to Plumsail Forms and does not affect Plumsail Forms forms on SharePoint :slight_smile:

Stepan

1 Like

Hi @Fritz77,

Could you provide screenshots of the whole console? This error doesn't seem very relevant indeed.
Additionally, you could export your form and send it to us at support@plumsail.com. That should make the whole debugging process much quicker

1 Like