<?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: Create line items with associations in Workflows in &amp;#128172 RevOps Discussions</title>
    <link>https://community.hubspot.com/t5/128172-RevOps-Discussions/Create-line-items-with-associations-in-Workflows/m-p/803055#M1872</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/459894"&gt;@PMcConnell&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This looks like an error with the HubSpot API client, looking at the logs for the token the client simply isnt sending the associations portion of the body:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JBeatty_0-1685978349297.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/92263iBC85C11A905FDEFD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JBeatty_0-1685978349297.png" alt="JBeatty_0-1685978349297.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I would recommend using axios as a work around, that way it stays as a single api call, you could do that by doing the following:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;const axios = require('axios').default;
exports.main = async (event, callback) =&amp;gt; {
    const client = axios.create({
        baseURL: 'https://api.hubapi.com',
        headers: {
            accept: 'application/json',
            Authorization: `Bearer ${process.env.APPTOKEN}`
        }
    });

    const properties = {
        "name": "test name",
        "hs_product_id": 1579739513,
        "quantity": "1",
        "price": "100.00"
    };
    await client.post(`/crm/v3/objects/line_items`, 
        { properties, associations: [{ "to": { "id": event.object.objectId }, "types": [{ "associationCategory": "HUBSPOT_DEFINED", "associationTypeId": 20 }] }] });

}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Best,&lt;/P&gt;</description>
    <pubDate>Mon, 05 Jun 2023 15:22:54 GMT</pubDate>
    <dc:creator>JBeatty</dc:creator>
    <dc:date>2023-06-05T15:22:54Z</dc:date>
    <item>
      <title>Create line items with associations in Workflows</title>
      <link>https://community.hubspot.com/t5/128172-RevOps-Discussions/Create-line-items-with-associations-in-Workflows/m-p/802133#M1867</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am running into a strange problem and hoping someone can shed some light on it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am trying to create a line item using Workflows.&amp;nbsp; This line item is to have an assocation to a deal.&amp;nbsp;&lt;BR /&gt;Below is a copy of my code with my parameters scrubbed.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt; const properties = {
  "name": "test name",
  "hs_product_id": product_id,
  "quantity": "1",
  "price": "100.00"
};
const SimplePublicObjectInputForCreate = { properties, associations: [{"to":{"id": deal_id},"types":[{"associationCategory":"HUBSPOT_DEFINED","associationTypeId":20}]}] };

try {
  const apiResponse = await hubspotClient.crm.lineItems.basicApi.create(SimplePublicObjectInputForCreate);
  console.log(JSON.stringify(apiResponse, null, 2));
} catch (e) {
  e.message === 'HTTP request failed'
    ? console.error(JSON.stringify(e.response, null, 2))
    : console.error(e)
}
  &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I can run this code through the endpoints on the hubspot docs pages and it all works fine.&amp;nbsp; However, when running it in workflows, the line item gets created but not associated.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I know the work around is just to run the associations api afterwards but I am wondering if I am using the line items api incorrectly.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any help is greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Pauric&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 06:57:37 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/128172-RevOps-Discussions/Create-line-items-with-associations-in-Workflows/m-p/802133#M1867</guid>
      <dc:creator>PMcConnell</dc:creator>
      <dc:date>2023-06-02T06:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create line items with associations in Workflows</title>
      <link>https://community.hubspot.com/t5/128172-RevOps-Discussions/Create-line-items-with-associations-in-Workflows/m-p/802431#M1870</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/459894"&gt;@PMcConnell&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reaching out to the Community!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to invite our subject matter experts to see if they have insight.&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/20261"&gt;@louischausse&lt;/a&gt;,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/193060"&gt;@JBeatty&lt;/a&gt;,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/241684"&gt;@ChrisoKlepke&lt;/a&gt;&amp;nbsp;- Do you have any advice for&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/459894"&gt;@PMcConnell&lt;/a&gt;?&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Kristen&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 19:04:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/128172-RevOps-Discussions/Create-line-items-with-associations-in-Workflows/m-p/802431#M1870</guid>
      <dc:creator>kvlschaefer</dc:creator>
      <dc:date>2023-06-02T19:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create line items with associations in Workflows</title>
      <link>https://community.hubspot.com/t5/128172-RevOps-Discussions/Create-line-items-with-associations-in-Workflows/m-p/803055#M1872</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/459894"&gt;@PMcConnell&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This looks like an error with the HubSpot API client, looking at the logs for the token the client simply isnt sending the associations portion of the body:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JBeatty_0-1685978349297.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/92263iBC85C11A905FDEFD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JBeatty_0-1685978349297.png" alt="JBeatty_0-1685978349297.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I would recommend using axios as a work around, that way it stays as a single api call, you could do that by doing the following:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;const axios = require('axios').default;
exports.main = async (event, callback) =&amp;gt; {
    const client = axios.create({
        baseURL: 'https://api.hubapi.com',
        headers: {
            accept: 'application/json',
            Authorization: `Bearer ${process.env.APPTOKEN}`
        }
    });

    const properties = {
        "name": "test name",
        "hs_product_id": 1579739513,
        "quantity": "1",
        "price": "100.00"
    };
    await client.post(`/crm/v3/objects/line_items`, 
        { properties, associations: [{ "to": { "id": event.object.objectId }, "types": [{ "associationCategory": "HUBSPOT_DEFINED", "associationTypeId": 20 }] }] });

}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Best,&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 15:22:54 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/128172-RevOps-Discussions/Create-line-items-with-associations-in-Workflows/m-p/803055#M1872</guid>
      <dc:creator>JBeatty</dc:creator>
      <dc:date>2023-06-05T15:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create line items with associations in Workflows</title>
      <link>https://community.hubspot.com/t5/128172-RevOps-Discussions/Create-line-items-with-associations-in-Workflows/m-p/862042#M2041</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi Everyone,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I work for a HubSpot Diamond Partner. We have developed an app for the marketplace that aims to solve the issue of displaying associated line items. Currently, line items associated with deals remain hidden in other relevant objects. This app bridges the gap by introducing CRM cards that unveil line item lists within associated objects.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;We are seeking beta testers who can try our app at no cost, provide valuable feedback, and assist us in enhancing the overall usability of the product.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-unicode-emoji" title=":backhand_index_pointing_right:"&gt;👉&lt;/span&gt; Join the Beta Test -&amp;gt; &lt;/SPAN&gt;&lt;A href="https://cdn.apps.exelab.com/2123298/consent" target="_blank"&gt;&lt;SPAN&gt;Installation link&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; &lt;span class="lia-unicode-emoji" title=":link:"&gt;🔗&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-unicode-emoji" title=":backhand_index_pointing_right:"&gt;👉&lt;/span&gt; &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;How it works&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN&gt; document -&amp;gt; &lt;/SPAN&gt;&lt;A href="https://exelab.com/hubfs/Apps%20Exelab/Show%20Line%20Items%20Association/Show%20Line%20Items%20Association%20-%20How%20it%20works.pdf" target="_blank"&gt;&lt;SPAN&gt;PDF&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;While you're here, don't forget to check out &lt;/SPAN&gt;&lt;A href="https://ecosystem.hubspot.com/marketplace/apps/all-categories?eco_search=Exelab" target="_blank"&gt;&lt;SPAN&gt;our other apps&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; in the HubSpot Marketplace for more helpful solutions!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 07:55:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/128172-RevOps-Discussions/Create-line-items-with-associations-in-Workflows/m-p/862042#M2041</guid>
      <dc:creator>Franci</dc:creator>
      <dc:date>2023-10-10T07:55:38Z</dc:date>
    </item>
  </channel>
</rss>

