Hi all,
I’m pretty new to the world of js so maybe I’m missing something obvious.
I’m trying to set up a form wherein:
I choose an internal staff lead for a project from my users
-and then-
That staff member’s email automatically populates in the email field.
kintone.getLoginUser will only make my email automatically populate, which isn’t helpful. I could, in theory, do it all through if/else statements, but (A) that seems silly when the system obviously tracks user emails and (B) I’d have to update the js every time I add / delete a new user.
Thoughts?
So, with some experimenting, I couldn’t even do this through if/else statements, because user selection answers are recorded as objects, not as the text of actual users’ names. =/
Hi Meg!
According to what I have read, I’m assuming that you are trying to:
1)Select a staff from such as the User Selection field
2)Acquire the e-mail address of the selected user
3)Display the acquired e-mail address to a field
If this is the case, it should be something like:
-
At the Change event, acquire the code information of the user selection field
-
Using the acquired information, obtain an e-mail address with the userAPI
<< Request Example >>
var parm = {
“codes”:“Acquired code information”
};
kintone.api(
‘/v1/users’,
‘GET’,
parm,
function(event){console.log(event);},
function(err){console.log(err);}
)
<< Response Example >>
{
“users”: [
{
“birthDate”: “2011-05-01”,
“callto”: “”,
“code”: “a”,
“ctime”: “2013-07-22T08:12:18Z”,
“customItemValues”: [
{
“code”: “item1”,
“value”: “aitem1”
},
{
“code”: “secret”,
“value”: “aitem2”
}
],
“description”: “”,
“email”: “mail.address.com”,
“employeeNumber”: “”,
“extensionNumber”: “”,
-(abbrv.)-
}
]
}
- Store the value in a field
I hope this helps!