<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using custom code to fetch a contact in a deal in Data Hub</title>
    <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555423#M582</link>
    <description>&lt;P&gt;Ok thanks and could you use a Contact triggered workflow instead of a Deal one?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;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.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jan 2022 10:50:48 GMT</pubDate>
    <dc:creator>Jonno_Price</dc:creator>
    <dc:date>2022-01-13T10:50:48Z</dc:date>
    <item>
      <title>Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/553823#M568</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to use custom code to fetch a certain contact from a deal.&lt;BR /&gt;&lt;BR /&gt;When a deal meets criteria (Note: Deal has 2+contacts in it) =&amp;gt; Deal gets enrolled in the workflow =&amp;gt; run custom code to fetch a certain contact from within this deal (either by contact id, contact type...)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 05:14:10 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/553823#M568</guid>
      <dc:creator>ChrisChiha</dc:creator>
      <dc:date>2022-01-12T05:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555115#M576</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/264909"&gt;@ChrisChiha&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for reaching out to us!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to tag in some of our experts into there since they would be able to have some insight&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/16801"&gt;@Drew_Cohen&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/93098"&gt;@JenBergren&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/93889"&gt;@jonnoprice&lt;/a&gt;&amp;nbsp;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/97401"&gt;@JenWeiss&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 21:46:54 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555115#M576</guid>
      <dc:creator>JenWeiss</dc:creator>
      <dc:date>2022-01-12T21:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555181#M577</link>
      <description>&lt;P&gt;Thanks for the tag! I do not have the answer but will tag in some other awesome minds from my team:&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/239226"&gt;@jspencerdav&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/137486"&gt;@jamesle&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/239826"&gt;@JBurgess&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/209661"&gt;@MAnderson42&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/207726"&gt;@VSonne&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/81925"&gt;@RemotishAgency&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 23:36:26 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555181#M577</guid>
      <dc:creator>JenBergren</dc:creator>
      <dc:date>2022-01-12T23:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555222#M578</link>
      <description>&lt;P&gt;Are the deals credited by API? Even if not, flexible associations comes to mind as a way to pull an individual contact.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 01:53:10 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555222#M578</guid>
      <dc:creator>jspencerdav</dc:creator>
      <dc:date>2022-01-13T01:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555407#M579</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/264909" target="_blank"&gt;@ChrisChiha&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Apologies if I misunderstannd the use case here but don't think custom code is needed? e.g. you simply use the enrollment criteria in a workflow. &lt;BR /&gt;&lt;BR /&gt;If deal meets X criteria and associated contact type = Y then do Z.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 10:24:21 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555407#M579</guid>
      <dc:creator>Jonno_Price</dc:creator>
      <dc:date>2022-01-13T10:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555411#M580</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/123669"&gt;@Jonno_Price&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Association labels are not feasible in my current project.&amp;nbsp;&lt;BR /&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 10:37:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555411#M580</guid>
      <dc:creator>ChrisChiha</dc:creator>
      <dc:date>2022-01-13T10:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555414#M581</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/239226"&gt;@jspencerdav&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;The deals are created by API.&amp;nbsp;&lt;BR /&gt;I was able to use the below code in the workflow "custom code" action to search for contacts of type customer in my CRM :&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;const hubspot = require('@hubspot/api-client');&lt;/SPAN&gt;&lt;SPAN&gt;exports.main = (event, callback) =&amp;gt; {&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;const hubspotClient = new hubspot.Client({&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;apiKey: process.env.hapikey&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;});&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;const filter = { propertyName: 'contact_type', operator: 'EQ', value: 'customer' }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;const filterGroup = { filters:&amp;nbsp;&amp;nbsp;&amp;nbsp; [filter]&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;limit&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;5&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;after&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;0&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;const conditions = {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;filterGroups: [filterGroup],&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;limit,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;after&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;hubspotClient.crm.contacts.searchApi.doSearch(conditions).then(searchDealResponse =&amp;gt; {&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var contact_type = 'customer';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;console.log(searchDealResponse.body.results)&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;callback({&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;outputFields: {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;contact_type: contact_type&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;})&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.catch(err =&amp;gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;console.error(err);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This code is returning all contacts in my CRM who have contact type: customer&lt;BR /&gt;I would like to implement the search on enrolled deal level only. Can this be done ?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 13:15:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555414#M581</guid>
      <dc:creator>ChrisChiha</dc:creator>
      <dc:date>2022-01-13T13:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555423#M582</link>
      <description>&lt;P&gt;Ok thanks and could you use a Contact triggered workflow instead of a Deal one?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;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.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 10:50:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555423#M582</guid>
      <dc:creator>Jonno_Price</dc:creator>
      <dc:date>2022-01-13T10:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555428#M583</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/123669"&gt;@Jonno_Price&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;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.)&amp;nbsp;&lt;BR /&gt;That's why i am stuck with deal-based workflow.&lt;BR /&gt;&lt;BR /&gt;And in many of my emails, personalized content from deals is mandatory in our communications.&lt;BR /&gt;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.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 11:03:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555428#M583</guid>
      <dc:creator>ChrisChiha</dc:creator>
      <dc:date>2022-01-13T11:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555473#M584</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/264909"&gt;@ChrisChiha&lt;/a&gt;&amp;nbsp;- 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.&lt;BR /&gt;&lt;BR /&gt;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 &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 12:34:16 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/555473#M584</guid>
      <dc:creator>Jonno_Price</dc:creator>
      <dc:date>2022-01-13T12:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/556171#M585</link>
      <description>&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 10:13:23 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/556171#M585</guid>
      <dc:creator>ChrisChiha</dc:creator>
      <dc:date>2022-01-14T10:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using custom code to fetch a contact in a deal</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/670741#M953</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/264909"&gt;@ChrisChiha&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Did you manage to figure this out?&amp;nbsp;&lt;BR /&gt;I can share my expertise with custom codes in workflows.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 07:29:09 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Using-custom-code-to-fetch-a-contact-in-a-deal/m-p/670741#M953</guid>
      <dc:creator>yesh_naik</dc:creator>
      <dc:date>2022-07-26T07:29:09Z</dc:date>
    </item>
  </channel>
</rss>

