Single Select People fields allowing multiple values

Home Forums Classic DFFS Single Select People fields allowing multiple values

Tagged: 

Viewing 1 reply thread
  • Author
    Posts
    • #38741
      Keith Hudson
      Participant

        We have a very complex classic DFFS form that has a people and groups field set to only allow one person. The field is named “CB Contract Signer” (FIN: ThirdPartyContractSigner). The field is misbehaving and allowing more than one name to be entered. Although attempting to save the form sometimes returns the focus to the misbehaving field where a red error message states “You can only enter one name”, some users have been able to proceed to another tab on the form and save the form without removing the second or third person. Is there some code we can add to the form that would immediately delete the first name in the field if a second name is added? This appears to be the behavior of that kind of field in a native SharePoint form. I’m attaching a screenshot showing two names in the field with the error message below.

      • #38743
        Alexander Bautz
        Keymaster

          The behavior you describe is how all single choice people pickers work, but the form should show this error and not allow saving. The validation of the field is done after the postback so it may look like it saves because the page reloads, but the for does not actually save.

          If you however have some kind of custom js or maybe are sending out emails using DFFS, these would be triggered on the save attempt.

          You can try adding this to your forms Custom JS:

          function ensureOnlyOnePP(fin){
              setInterval(() => {
                  const arr = spjs.utility.getFieldValue({"fin": fin, "key": "loginname"});
                  if(arr.length > 1){
                      // Clear unresolved users
                      document.querySelector("#dffs_" + fin).querySelector(".sp-peoplepicker-editorInput").value = "";
                      // Clear field
                      setFieldValue(fin, "");
                      // Set first value in array
                      setFieldValue(fin, arr[0]);
                  }
              },1000);
          }
          ensureOnlyOnePP("ThirdPartyContractSigner");
          

          Alexander

      Viewing 1 reply thread
      • You must be logged in to reply to this topic.