Allow only 1 user for User Selection fields

Introduction

User Selection fields in kintone can hold information of multiple users. The number of users that can be selected for the value though cannot be controlled with kintone's in-built features.

There are some cases though where we would like to use the User Selection field for selecting managers or ticket requestors, and those fields should usually only consist of one user.

 

This issue can be solved by using some JavaScript customization.

This article introduces a customization to allow only one user to be selected in the User selection field.

Preparing the App

Prepare the App where you would like to apply the customization. The only field needed for this customization to run is the User Selection field, so make sure this field is included, and take note of the field code.

US_01.PNG

 

Source Code

Code Explanation

  • The User Selection field holds values in an array. If the length of the array is 2 or more, the code places an error message inside event.error and returns the event object.

Test the Customization

Apply this source code to the kintone App prepared in the previous steps.

Try specifying 2 or more users in the User Selection field on the Record Create page, Record Edit page and the Record List page. If successful, and error message will appear, and the user will not be able to save the record.

US_1.gif

Was this article helpful?
0 out of 0 found this helpful
Comments
Please sign in to leave a comment.