Disable People Picker Field

Hello,

Can people picker field be disabled? I have tried using the following code to disable the people picker field but it doesn't work.

fd.field('PeoplePicker').disabled = true;

I also tried to use ReadOnly and it doesn't work either.

fd.field('PeoplePicker').ReadOnly = true;

Any help would be appreciated.

Dear @COR6603,
Person field takes time to load, please, make sure to run all the operations inside of the ready method:

fd.spRendered(function(){
  fd.field('Person').ready().then(function(field) {
    field.disabled = true;
  });
});

I am looking to build a one where,

if the people pick field is not empty, disable it. How do I do that

@Nikita_Kurguzov

Dear @IT.Joe,
You can try the following:

fd.spRendered(function(){
  fd.field('Person').ready().then(function(field) {
    if(!field.value){
      field.disabled = true;
    }  
});
});

I'm not sure if I did it wrong but I copy and pasted the entire code in. Then change to the field name. It doesn't disable still when there's already value in it.

Thought?

Dear @IT.Joe,
I might've misread the original intent, please, try it like this:

fd.spRendered(function(){
  fd.field('Person').ready().then(function(field) {
    if(field.value){
      field.disabled = true;
    }  
  });
});

This should disable the field if it already has a value in it.

I am trying to disable a people field following some of the info above but it doesn't seem to be working for me. I am trying to incorporate it into disabling multiple fields. My code looks like this:

fd.spRendered(function() {

    fd.field('Signature').ready().then(function disablePurchasing() {
        if (fd.field('Status').value == 'New' || fd.field('Status').value == 'Pending Approval' ) {
            // Setting fields for Step 3 to a disabled state
            fd.field('Field 1').disabled = true;
            fd.field('Field 2').disabled = true;
            fd.field('Signature').disabled = true;
            
        }
        else{
            // Setting field Step 3 to an editable state
            fd.field('Field 1').disabled = false;
            fd.field('Field 2').disabled = false;
            fd.field('Signature').disabled = false;
        }
    }

    fd.field('Field 1').$on('change',disablePurchasing);
    fd.field('Field 2').$on('change',disablePurchasing);
   
    // Calling disablePurchasing on form loading
    disablePurchasing();
)});

Dear @volkjr,
Your code more likely should look like this:

fd.spRendered(function() {
    function disablePurchasing() {
        if (fd.field('Status').value == 'New' || fd.field('Status').value == 'Pending Approval' ) {
            // Setting fields for Step 3 to a disabled state
            fd.field('Field 1').disabled = true;
            fd.field('Field 2').disabled = true;
            fd.field('Signature').disabled = true;
        }
        else{
            // Setting field Step 3 to an editable state
            fd.field('Field 1').disabled = false;
            fd.field('Field 2').disabled = false;
            fd.field('Signature').disabled = false;
        }
    }
    fd.field('Field 1').$on('change',disablePurchasing);
    fd.field('Field 2').$on('change',disablePurchasing);
   
    // Calling disablePurchasing on form loading
    fd.field('Signature').ready().then(function(){
        disablePurchasing();
    });
});