I want to build an automated system that notifies customers when products come back in stock. My plan is to save customer email addresses in a product metafield as a comma-separated string, then use Flow to read this data and send individual emails when inventory is replenished.
My current workflow looks like this:
Scheduled trigger → Product data retrieval → Code execution → Output logging
I can see the email list when I log the metafield directly, but I’m struggling to access these emails within the code execution step where I need to parse them and send notifications.
I’m having trouble understanding how the code execution section works. I’ve tried querying the metafield in the inputs:
query {
product {
metafield(namespace: "custom", key: "stock_notification_emails") {
value
}
}
}
This always returns NULL when I log it. I also tried accessing it directly in the code:
const emailList = input.stock_notification_emails;
This also returns NULL. How do I properly access metafield data within the code execution step?
Another problem is that the marketing message action seems to require customer IDs instead of email addresses. Is there a way to convert email addresses to customer IDs?
Am I approaching this correctly or is there a better method?