# Create line items with associations in Workflows

**URL:** <https://community.hubspot.com/t/create-line-items-with-associations-in-workflows/82523>\
**Category:** 💬 RevOps Discussions\
**Tags:** revops\
**Created:** [June 2, 2023, 6:57am UTC](https://community.hubspot.com/t/create-line-items-with-associations-in-workflows/82523 "2023-06-02T06:57:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PMcConnell](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pmcconnell/32/82468_2.png) [@PMcConnell](https://community.hubspot.com/u/PMcConnell)\
**Post date:** [June 2, 2023, 6:57am UTC](https://community.hubspot.com/t/create-line-items-with-associations-in-workflows/82523/1 "2023-06-02T06:57:37Z")

</div>

Hi all,  
I am running into a strange problem and hoping someone can shed some light on it.  
I am trying to create a line item using Workflows. This line item is to have an assocation to a deal.  
Below is a copy of my code with my parameters scrubbed.

```lia-code-sample
 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)
}

```

I can run this code through the endpoints on the hubspot docs pages and it all works fine. However, when running it in workflows, the line item gets created but not associated.  
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.  
Any help is greatly appreciated.  
Thanks,  
Pauric

---

<div class="post-metadata">

**Author:** ![kvlschaefer](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kvlschaefer/32/71076_2.png) [@kvlschaefer](https://community.hubspot.com/u/kvlschaefer)\
**Post date:** [June 2, 2023, 7:04pm UTC](https://community.hubspot.com/t/create-line-items-with-associations-in-workflows/82523/2 "2023-06-02T19:04:36Z")

</div>

Hi @PMcConnell,

Thanks for reaching out to the Community!

I wanted to invite our subject matter experts to see if they have insight.

Hi @louischausse, @JBeatty, @ChrisoKlepke - Do you have any advice for @PMcConnell?

Thank you!

Best,

Kristen

---

<div class="post-metadata">

**Author:** ![JBeatty](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jbeatty/32/52252_2.png) [@JBeatty](https://community.hubspot.com/u/JBeatty)\
**Post date:** [June 5, 2023, 3:22pm UTC](https://community.hubspot.com/t/create-line-items-with-associations-in-workflows/82523/3 "2023-06-05T15:22:54Z")

</div>

Hi @PMcConnell,

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:

 ![JBeatty_0-1685978349297.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/2/c/2caff54be9f03da777d2b16e70038e5794d70fbb.png)

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:

```lia-code-sample
const axios = require('axios').default;
exports.main = async (event, callback) => {
 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 }] }] });

}

```

Best,

---

<div class="post-metadata">

**Author:** ![Franci](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/franci/32/225468_2.png) [@Franci](https://community.hubspot.com/u/Franci)\
**Post date:** [October 10, 2023, 7:55am UTC](https://community.hubspot.com/t/create-line-items-with-associations-in-workflows/82523/4 "2023-10-10T07:55:38Z")

</div>

Hi Everyone,

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.

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.

👉 Join the Beta Test → [Installation link](https://cdn.apps.exelab.com/2123298/consent) 🔗

👉 _How it works_ document → [PDF](https://exelab.com/hubfs/Apps%20Exelab/Show%20Line%20Items%20Association/Show%20Line%20Items%20Association%20-%20How%20it%20works.pdf)

While you’re here, don’t forget to check out [our other apps](https://ecosystem.hubspot.com/marketplace/apps/all-categories?eco_search=Exelab) in the HubSpot Marketplace for more helpful solutions!

Cheers!
