Autofill User Details

I would like to auto fill certain fields with information from a users profile such as email, phone number, and job title. How do I create a customization to auto fill these fields?

Hi Rich.

If you need login user information, you can get information such as email with kintone.getLoginUser.

Get Logged-in User

https://developer.kintone.io/hc/en-us/articles/212494428/

 

Hello Rich.

This is a code sample to fill some fields from login user information Minoru refered.
Job title is not supported by Javascript API for now.

kintone.events.on([“app.record.create.show”], function(e) {
  var user = kintone.getLoginUser();
  e.record.email.value = user.email;
  e.record.phone.value = user.phone;
  return e;
});

hi Ryo,

Can we fill in user profile data base on user selection ? ( base on your coding above)

example :

User select “A” then email and phone number auto fill in.

Hello Trithot!

You can utilize the Get User API(/v1/users.json) to obtain user info.

Kintone Developer Program - Get Users
https://developer.kintone.io/hc/en-us/articles/115008421668-Get-Users

The following is the code that I found to display email of a user selected in the User Selection field:

(function () {
"use strict";
kintone.events.on([
'app.record.create.change.UserSelect',
'app.record.edit.change.UserSelect'
], function(event){
if(event.record.UserSelect.value.length !== 1) return;
kintone.api(kintone.api.url('/v1/users', true), 'GET', {}).then(function(response){
event.record.FieldtoShowEmail.value = response.users.find(function(user){
return user.name === event.record.UserSelect.value[0].name;
}).email;
kintone.app.record.set(event);
});
});
})();

FYI, the max request parameter is 100, so you can only obtain up to 100 ids. To do more, you need to add loops.

I hope this helps.