Jan 11, 20227:57 AM - edited Jan 12, 202212:14 AM
Top Contributor
Using custom code to fetch a contact in a deal
SOLVE
Hello guys,
I would like to use custom code to fetch a certain contact from a deal.
When a deal meets criteria (Note: Deal has 2+contacts in it) => Deal gets enrolled in the workflow => run custom code to fetch a certain contact from within this deal (either by contact id, contact type...)
I was able to fetch a contact by adding his email as a property in the deal, and then calling this property from the enrolled deal using my custom code. My next step will be to figure out how to enroll this email that i fetched in a new workflow using the enroll API.
I was able to fetch a contact by adding his email as a property in the deal, and then calling this property from the enrolled deal using my custom code. My next step will be to figure out how to enroll this email that i fetched in a new workflow using the enroll API.
Jan 13, 20225:30 AM - edited Jan 13, 20225:37 AM
Top Contributor
Using custom code to fetch a contact in a deal
SOLVE
Hi @Jonno_Price , The thing about the Deal based workflow is it trigger the send email action to all contacts associated to this deal. Even if i do an if branch to check for contact type, when the deal reached the send email action for example, the deal-based workflow send an email to all contacts associated to this deal.
Association labels are not feasible in my current project. I was told to use SearchAPI and AsspciationAPI in the custom code to be able to search inside the deal for contacts by filtering certain properties. But it is giving some hard time as i am not a developer.
Jan 13, 20225:50 AM - edited Jan 13, 20225:50 AM
Guide | Platinum Partner
Using custom code to fetch a contact in a deal
SOLVE
Ok thanks and could you use a Contact triggered workflow instead of a Deal one?
This should allow you to only enrol the contact which meets the contact criteria.. A tip is to use an Active list to create the mix of criteria on Deal and Contact level that you want. Then the workflow is a Contact Workflow where enrolment is based on list membership.
Jan 13, 20225:56 AM - edited Jan 13, 20226:03 AM
Top Contributor
Using custom code to fetch a contact in a deal
SOLVE
@Jonno_Price , Taking the "email send" action as an example, if we have personalization tokens in the email that are fetched from a deal, Hubspot wont let me integrate this email in a contact-based workflow. (So on the send email action inside the contact-based workflow, the email template can't be chosen.) That's why i am stuck with deal-based workflow.
And in many of my emails, personalized content from deals is mandatory in our communications. So that's why i thought of maybe finding a way to fetch the required contact from the enrolled deal based on certain properties, and then enroll him in another workflow that will take him throughout a new user journey.
Hi @ChrisChiha - yep run into same issue and my only solve was to create equivalent properties on the contact level and copy the values from deal to contact in order to use in an email. This may or may not be feasible in your case depending on the number of properties.
If you find the solution for calling a specific contact (using code as per your original post) so that you can isolate them in a deal workflow for email purposes pls do share an update here 🙂
Jan 13, 20225:34 AM - edited Jan 13, 20228:15 AM
Top Contributor
Using custom code to fetch a contact in a deal
SOLVE
@jspencerdav The deals are created by API. I was able to use the below code in the workflow "custom code" action to search for contacts of type customer in my CRM :
This code is returning all contacts in my CRM who have contact type: customer I would like to implement the search on enrolled deal level only. Can this be done ?