<?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: Issue with my code not writing data back to a Deal with the updated value in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/837517#M66641</link>
    <description>&lt;P&gt;Done! Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 21 Aug 2023 12:23:08 GMT</pubDate>
    <dc:creator>RReiffer</dc:creator>
    <dc:date>2023-08-21T12:23:08Z</dc:date>
    <item>
      <title>Issue with my code not writing data back to a Deal with the updated value</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/809755#M65051</link>
      <description>&lt;P&gt;All,&lt;/P&gt;
&lt;P&gt;I am trying to do the following in Deals.&amp;nbsp; If the amount is null or = 0 then replace the amount with the Total Contract Value (hs_tcv).&amp;nbsp; My flow appears to do everything, no errors but the amount field stays blank.&amp;nbsp; Below is the code and a screen shot of my input and output variables.&lt;/P&gt;
&lt;DIV&gt;const hubspot = require('@hubspot/api-client');&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;exports.main = async (event, callback) =&amp;gt; {&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; const hubspotClient = new hubspot.Client({&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; accessToken: "pat-na1-NOPE"&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; });&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; //console.log("Made it past OAuth")&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; //First, make a call to get deal associations&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; var amount = event.inputFields['amount'];&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //console.log(amount)&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var hs_mrr = Number(event.inputFields['hs_mrr']);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; var hs_tcv = event.inputFields['hs_tcv'];&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; //const closedate = event.inputFields['closedate'];&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;//console.log(hs_tcv)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; //console.log("1",amount)&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; var amount_new = amount&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(amount_new &amp;gt; 0) {var amount_new = amount} else {var amount_new = hs_tcv}&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //console.log("2",amount_new)&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; amount = amount_new&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //console.log("3", amount)&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; callback({&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; outputFields: {&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; amount: amount&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RReiffer_0-1687281986121.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/93338i4B3C41AEC80BDD66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RReiffer_0-1687281986121.png" alt="RReiffer_0-1687281986121.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:03:57 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/809755#M65051</guid>
      <dc:creator>RReiffer</dc:creator>
      <dc:date>2023-07-10T19:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with my code not writing data back to a Deal with the updated value</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/809764#M65052</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/101258" target="_blank"&gt;@Teun&lt;/A&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/20261" target="_blank"&gt;@louischausse&lt;/A&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/10166" target="_blank"&gt;@johnelmer&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;- here is the code I was referring to.&amp;nbsp; Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2023 17:43:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/809764#M65052</guid>
      <dc:creator>RReiffer</dc:creator>
      <dc:date>2023-06-20T17:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with my code not writing data back to a Deal with the updated value</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/809772#M65054</link>
      <description>&lt;P&gt;Hey everyone, I finally figured it out (duh).&amp;nbsp; I needed to add a step in the workflow that actually copies that value BACK to the deal from the custom code.&amp;nbsp; &amp;nbsp;I assumed that the code actually wrote data back but it only writes data back to the custom code workflow object.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RReiffer_0-1687284455592.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/93341i51DE21D01254BA74/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RReiffer_0-1687284455592.png" alt="RReiffer_0-1687284455592.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2023 18:07:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/809772#M65054</guid>
      <dc:creator>RReiffer</dc:creator>
      <dc:date>2023-06-20T18:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with my code not writing data back to a Deal with the updated value</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/814146#M65328</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/513971"&gt;@RReiffer&lt;/a&gt;&amp;nbsp;, Glad to see you found a solution to this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did notice that in your initial post you've used what looks like your access token. Just wanted to make sure that you changed this as otherwise people can access your Hubspot data via API with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Happy Hubspotting!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2023 09:56:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/814146#M65328</guid>
      <dc:creator>KimM</dc:creator>
      <dc:date>2023-06-30T09:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with my code not writing data back to a Deal with the updated value</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/817831#M65535</link>
      <description>&lt;P&gt;Good catch,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/57728"&gt;@KimM&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":raising_hands:"&gt;🙌&lt;/span&gt; I went ahead and edited it out of the original post. And,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/513971"&gt;@RReiffer&lt;/a&gt;&amp;nbsp;should definitely rotate that key if they haven't already. — Jaycee&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:05:30 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/817831#M65535</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2023-07-10T19:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with my code not writing data back to a Deal with the updated value</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/837153#M66610</link>
      <description>&lt;P&gt;Hi Richard, I'm curious why you wrote custom code for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your Deal workflow:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;triggers on MRR property is 'known', and permits deal re-enrollment&lt;/LI&gt;
&lt;LI&gt;then copies the Deal MRR property to Deal Amount&lt;/LI&gt;
&lt;LI&gt;will that also suffice?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;best&lt;/P&gt;
&lt;P&gt;Pete&lt;/P&gt;</description>
      <pubDate>Sun, 20 Aug 2023 10:21:58 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/837153#M66610</guid>
      <dc:creator>HubDoPete</dc:creator>
      <dc:date>2023-08-20T10:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with my code not writing data back to a Deal with the updated value</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/837516#M66640</link>
      <description>&lt;P&gt;Pete,&lt;/P&gt;&lt;P&gt;Wew wanted to have Total Contract Value and not MRR.&lt;/P&gt;&lt;P&gt;Rich&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 12:22:37 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/837516#M66640</guid>
      <dc:creator>RReiffer</dc:creator>
      <dc:date>2023-08-21T12:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with my code not writing data back to a Deal with the updated value</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/837517#M66641</link>
      <description>&lt;P&gt;Done! Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 12:23:08 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/837517#M66641</guid>
      <dc:creator>RReiffer</dc:creator>
      <dc:date>2023-08-21T12:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with my code not writing data back to a Deal with the updated value</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/837520#M66642</link>
      <description>&lt;P&gt;Hi Richard, in that case, could you just copy across the Deal TCV?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;workflow triggers on TCV property is 'known', and permits deal re-enrollment&lt;/LI&gt;
&lt;LI&gt;then copies the Deal TCV property to Deal Amount&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;That property is also automatically updated by HubSpot per deal. If you need custom code then sure thing - I was just curious as there are four calculated fields on each deal that you can copy to deal amount:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Total contract value (&lt;STRONG&gt;TCV&lt;/STRONG&gt;),&lt;/LI&gt;
&lt;LI&gt;Annual contract value (&lt;STRONG&gt;ACV&lt;/STRONG&gt;),&lt;/LI&gt;
&lt;LI&gt;Annual recurring revenue (&lt;STRONG&gt;ARR&lt;/STRONG&gt;)&lt;/LI&gt;
&lt;LI&gt;and Monthly recurring revenue (&lt;STRONG&gt;MRR&lt;/STRONG&gt;).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;We ended up writing a &lt;A href="https://help.hubdo.com/dopricer/set-deal-amount" target="_blank" rel="noopener"&gt;help page on automating deal value&lt;/A&gt; because it comes up regularly for apps like DoPricer which change line item prices and discounts in the background via the API. So the workflow keeps the deal amount accurate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best&lt;/P&gt;
&lt;P&gt;Pete&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 12:29:57 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issue-with-my-code-not-writing-data-back-to-a-Deal-with-the/m-p/837520#M66642</guid>
      <dc:creator>HubDoPete</dc:creator>
      <dc:date>2023-08-21T12:29:57Z</dc:date>
    </item>
  </channel>
</rss>

