Add yourself to a user field with one click

Introduction

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.

We can use JavaScript customization to solve this issue.

Customization image

Clicking the button will add yourself to the User selection field.

US_1.PNG

 

US_2.PNG

 

The flow of the code

The JavaScript custmization will do the following:

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:

 

Finally

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.

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