In this article, we introduce how to add yourself to a User selection field with a click of a button.
Imagine a scenario where you are using a kintone App to manage tasks for your team. This App would include a User field that shows who the assignee is. If you need to allocate a task to your self, you would need to click the Edit button, select the User field, find your name, then save the record. As there are many mouse clicks involved, this becomes a bit tedious when you need to repeat this process over and over again.
Clicking the button will add yourself to the User selection field.
The flow of the code
1. Create a button and add an event listener.
2. Add the logged-in user to the User field when the button is clicked.
First, set a Record Details event so that we can add a button when the record details page loads.
Next, create a button on a Blank space element.
Then, set an Event listener on the button.
When the button is pressed, call the addMemberMine() function.
*addEventListener() is not supported in IE. Please use attachEvent() for IE.
Now with this set, the addMemberMine() function will be called when the button is clicked.
The addMemberMine() function is as below:
With these codes combined, this code will add the user viewing the record (often referred to as the "logged-in user") to the user selection field with a simple button click. This can be used for scenarios other than Task management, and fits in well with Apps that have Process Management settings.