Best answer

Monday zap issue

  • 11 October 2023
  • 5 replies
  • 52 views

Userlevel 1

I have a zap that’s mostly working except it only updates the top row on my board. Looking for some troubleshooting help or a new approach. 

Here’s what I’m trying to accomplish:
-Every day (using zapier scheduler as the trigger), the zap should look for rows on my Monday board that has a date matching today’s date, it sends an email using a webhook and mixmax, then updates a few columns for the row. The date column for each row is a text field with multiple dates in the format Oct 11, 2023|Oct 12, 2023|etc. I have a custom python script that breaks up the dates, checks for today’s date, and also updates this email schedule (removing today’s date when the email for today is sent). 

Zap steps:
1. Trigger using Zapier scheduler
2. Get Board values 
3. Run python script
4. POST to mixmax using webhook
5. “Change multiple column values” in Monday

The problem is that all rows show up in step 2, but I can’t seem to pass the dynamic id field to step 3, so instead the zap just always updates the top row of the board. I want this to loop until all rows with today’s date have been emailed and updated. 


For the input data in step 3, I’m only able to select one of the rows values from step 2. 



Is there a way for me to create this loop? Or maybe a better way of accomplishing the task in general?


here’s the python script in case it’s helpful
 

# Fetch the data from the prior Zapier step 
deposit_schedule_string = input_data['DepositSchedule'] # e.g., "10/10/2023|10/17/2023|10/24/2023..."
deposits_made = int(input_data['DepositsMade'].replace('"', ''))
total_deposits = int(input_data['TotalDeposits'].replace('"', ''))
current_date = input_data['CurrentDate'] # The current date as fetched from the initial trigger or a date formatting step

# Split the string into a list of dates
deposit_dates = deposit_schedule_string.split('|')

# Find the position of the current date in the list
try:
deposit_number = deposit_dates.index(current_date) + 1 # +1 because list indices start at 0
except ValueError:
raise Exception("Today's date not found in the deposit schedule!")

# Increment the deposits made value
deposits_made += 1

# Remove the current date from the list
deposit_dates.remove(current_date)

# Convert the list back into a string
updated_deposit_schedule = '|'.join(deposit_dates)

# Return the updated values and the current deposit number for use in subsequent Zapier steps
output = {
'UpdatedDepositsMade': deposits_made,
'UpdatedDepositSchedule': updated_deposit_schedule,
'DepositNumber': deposit_number
}

return output

 

icon

Best answer by Todd Harper 11 October 2023, 22:28

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.

5 replies

Userlevel 7
Badge +14

Hi @MC_Ben 

Good question.

The Looping app can be used to handle iterations: https://zapier.com/apps/looping/help

Userlevel 1

Thanks for the response @Troy Tessalone! I’m not sure that I’m utilizing the loop correctly (see below). It looks like it’s only passing one of the item ids into the loop (shouldn’t there be a dynamic column that I can use?)

 

 

Userlevel 6
Badge +8

Because of the way monday.com sends and receives data from its Zapier app, I tend to recommend my clients to avoid using it at all costs (the Zapier integration specifically, not monday.com generally, to be clear). I would instead suggest using a code (best) or web hook (easier, but not ideal) step to get the board values from monday. I don’t write in Python, but this should help you get started:

output = { data: '' }

const appKey = "YOUR_API_KEY_HERE";
const boardId = "YOUR_BOARD_ID_HERE";
const query = `query {boards (ids: ${boardId}){ items_page {cursor items {id name column_values {id text}}}}}`;
let appData = "";

try {
const appResp = await fetch(
`https://api.monday.com/v2`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': appKey,
'API-Version': '2023-10'
},
body: JSON.stringify({
'query': query
})
}
);
appData = await appResp.text();
appData = JSON.parse(appData);
output.data = appData;
} catch (e) {
console.log(e.message);
}

This will return much easier to parse and iterate JSON data.

You could then proceed in the code to use for loops that iterate through each item and column value, perform the conditional logic you were using in your Python step, and continue to use in the rest of your Zap using Looping by Zapier (or, my preference, just do all actions following the trigger in a single code step).

If all of that sounds like gibberish to you, I would recommend hiring a Certified Zapier Expert to work with you on building this out.

Userlevel 1

Thanks, @Todd Harper ! removed my python code and put everything in the javascript step. All rows are now moving through the zap and looping! 

Userlevel 6
Badge +8

Thanks, @Todd Harper ! removed my python code and put everything in the javascript step. All rows are now moving through the zap and looping! 

Awesome! Glad to hear it!