Best answer

How do I look up for values that are not present in another list?

  • 15 January 2023
  • 3 replies
  • 38 views

  • Anonymous
  • 0 replies

Hi there! I’m trying to set up a zap that triggers a notification if a EmployeeCode is not present in today’s entry logs.

I have both variables: EmployeeCode that says which employees should have been present and EmployeeLog that states employee codes present on today’s records. How could I filter EmployeeCode if it’s not present in EmployeeLog?

I tried with JS Code by passing them as a dictionary but I can’t seem to find the way.

Is there a simpler approach to this?

 

Thanks in advance!

icon

Best answer by Todd Harper 15 January 2023, 23:23

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 6
Badge +8

Hi @GPozzi!

Would you provide a little more context for this? ie. Screenshots of the code you tried? Are EmployeeCode and EmployeeLog arrays? What do you then need to happen with the information?

Here’s a quick piece of JavaScript that does what I think you’re asking, but let me know if that’s not it:

var EmployeeCode = ["ABC123", "DEF456", "GHI789"]; // These employees were expected
var EmployeeLog = ["ABC123", "GHI789"] // These employees were present
var NotPresent = [];

// Next, we will determine which employees were not present by passing each expected employee through the array of present employees.
// We will append the absent employee to the "NotPresent" array.
for (var i = 0; i < EmployeeCode.length; i++) {
if (!EmployeeLog.includes(EmployeeCode[i])) {
NotPresent.push(EmployeeCode[i]);
}
}

output = [{NotPresent}] // 👉🏻 ["DEF456"]

 

Hi @GPozzi!

Would you provide a little more context for this? ie. Screenshots of the code you tried? Are EmployeeCode and EmployeeLog arrays? What do you then need to happen with the information?

Here’s a quick piece of JavaScript that does what I think you’re asking, but let me know if that’s not it:

var EmployeeCode = ["ABC123", "DEF456", "GHI789"]; // These employees were expected
var EmployeeLog = ["ABC123", "GHI789"] // These employees were present
var NotPresent = [];

// Next, we will determine which employees were not present by passing each expected employee through the array of present employees.
// We will append the absent employee to the "NotPresent" array.
for (var i = 0; i < EmployeeCode.length; i++) {
if (!EmployeeLog.includes(EmployeeCode[i])) {
NotPresent.push(EmployeeCode[i]);
}
}

output = [{NotPresent}] // 👉🏻 ["DEF456"]

 

Wow Todd, that’s exactly what I’ve been looking for! Sorry for not being so clear, but that totally solves my question

Userlevel 6
Badge +8

Glad I was able to help!