We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
May 25, 2022 2:40 AM - edited May 26, 2022 12:03 AM
Hello,
I am sending a daily digest to my partners that is being populated from my hubdb table, and is being triggered by a workflow. (The HubDB table is being filled daily from my Backend)
How it is currently working:
If the email address enrolled in the wokflow, is found in the HubDB table, then the row is fetched to the communication. The daily digest is working great right now, but now, even if the email address is not found in the hubdb table, the email is enrolled in the wokrflow.
I would like to know if it is possible to only send the email to enrolled people in the workflow, if their email address is present in the hubdb table.
I have a list of partners that are being enrolled in my workflow. Ideally, what i want to achieve; If the enrolled partner email is not found in the HubDB table column "email", i don't want the email communication to be triggered to him. is this possible?
Another question i had in mind:
Is it possible to trigger a workflow when a new row is added to the hubdb table ?
Solved! Go to Solution.
a month ago
Hi @ChrisChiha ,
I wrote this real quick, so could be some errors, but it could look something like this:
const axios = require('axios');
exports.main = async (event, callback) => {
const email = event.inputFields['email'];
let rowFound = false
const result = await axios({
method: 'get',
headers: { 'content-type': 'application/json' },
url: `https://api.hubapi.com/cms/v3/hubdb/tables/${tableId}/rows?portalId=${portalId}&limit=1&email__eq=${email}`,
}).then((response) => {
console.log(response.data)
if (response.data && response.data.results) {
rowFound = true
}
}).catch((error) => {
console.log(error)
})
callback({
outputFields: {
rowFound: rowFound
}
});
}
You can then use the 'rowFound' property in the output to handle the following steps of your workflow (you might have to use the Copy to Property action first).
a month ago
Hi @ChrisChiha ,
Do you have Operations Hub? If so, you can write a coded action that checks if a row exists and you can use the output to create a if / then branch to decide if you want to send the e-mail.
a month ago
Hello @Teun,
Yes that's what i was trying to achieve, adding a custom code at the beginning of the workflow to check if the email is found in any of the hubdb table rows.
I have operations hub and marketing enterprise.
Do you have any sample or documentation that might help/guide me in writing this custom code?
Thank you!
a month ago
Hi @ChrisChiha ,
I wrote this real quick, so could be some errors, but it could look something like this:
const axios = require('axios');
exports.main = async (event, callback) => {
const email = event.inputFields['email'];
let rowFound = false
const result = await axios({
method: 'get',
headers: { 'content-type': 'application/json' },
url: `https://api.hubapi.com/cms/v3/hubdb/tables/${tableId}/rows?portalId=${portalId}&limit=1&email__eq=${email}`,
}).then((response) => {
console.log(response.data)
if (response.data && response.data.results) {
rowFound = true
}
}).catch((error) => {
console.log(error)
})
callback({
outputFields: {
rowFound: rowFound
}
});
}
You can then use the 'rowFound' property in the output to handle the following steps of your workflow (you might have to use the Copy to Property action first).
4 weeks ago - last edited 4 weeks ago
Hello @Teun ,
I was able to get this code working, but it is always returning True even when there is no match. The outcome is right (Giving me 0 matches), but the code is still considering as True. I guess the problem is with the If statement, as it is considering any log as "True", even if the log is showing no matches.
UPDATE:
It worked, just had to replace the if statement by the below. Thank you !!
if (response.data.total > 0) {
rowFound = true
}
4 weeks ago
May 25, 2022 4:12 PM
This sounds like an interesting project!
Going to throw a few folks into this to see what comes of it
@tmcmillan99 , @Anton , @Josh , @Chriso-mwx what do you all think?
@tmcmillan99 and @Chriso-mwx are already having an interesting discussion on Custom Objects vs HubDB 😀
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |