Best way to grab user email addresses from either Department member or group member, if possible

Hi All,

Is there way to be able to grab a users email address if a department or group is selected?

I am building a kintone and have request that when a department(s) are selected that the managers of that department or departments receive and email. I use Zapier for my custom emails but am having a hard time trying to pull out the managers email address just from information from either a department or group. One note - There could be multiple depts or groups selected at the same time and I would need to be able to place those multiple email addresses into my email cc within zapier. Thank you for your time.

2 Likes

Adding a picture of my build

1 Like

Hello @dpoetsch

I'm not sure how you're currently distinguishing between regular users and managers within the department, but I assume you're using the Job Title feature in Kintone to make that distinction.

While I'm not entirely familiar with the full capabilities of Zapier, on the Kintone side, the general flow would be as follows:

  1. Use the Get Department's Users API to retrieve users who belong to the selected department(s).
  2. Filter the returned users based on their Job Title (e.g., only those with the title "Manager").
  3. Collect the corresponding email addresses and place them into a Text Area field. (This field is ideal because it can hold more characters than a regular text field.)
  4. Use the value of that Text Area field in your Zapier integration.

Hi @Chris,

Thank you for taking a look and your suggestion. I was able to get it to work using Zapiers Run Script Action. Within that action I was able to figure out a javascript that runs when that step is activated through a trigger. Below is my example, the email addresses are fake for testing purposes:
This is the Run Javascript Step. Within it I can write custom javascript
image

After the code is ran and the emails are collected, I then need to spilt the output so that each email address is seperate, then I can put that output into the email CC section.

This is the code:
const departmentEmailMap = {
"Operations Group": [
"opstest@example.com",
"test2@example.com"
],
"Supply Chain Management": [
"test2@example.com",
"scmtest@example.com"
],
"Warehouse": [
"test2@example.com",
"whsetesth@example.com"
],
"Quality Assurance & Safety Group": [
"test2@example.com",
"qastesth@example.com"
],
"Quality Control Group": [
"test2@example.com",
"qctesth@example.com"
],
"Management Team": [
"test2@example.com",
"mgmttest@example.com"
],

// Add more mappings as needed
};

// Split the input string into an array of departments
const departments = (inputData.involved_dept || '').split(',').map(dept => dept.trim());

// Create an array to hold the email addresses
const emailAddresses = departments
.map(dept => departmentEmailMap[dept])
.filter(email => email); // Filter out any undefined values

// Join the email addresses into a single string
output = { cc_emails: emailAddresses.join(',') };

So far testing is going good and it is working as intended.