> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add quote line

> How to create a quote line with CRMScript.

Because `CreateQuoteLine()` takes the ID of the quote alternative, it's automatically linked up to an alternative, a version, a quote, and a sale.

You can choose to add a product by its ERP info or as an `NSProduct`. In either case, you should set the quantity and any discounts for the selected product.

## Create from product key

```crmscript! theme={null}
Integer altId = 1;
String erpProductKey = "3412-20";
NSQuoteAgent qa;

NSQuoteLine line = qa.CreateQuoteLine(altId, erpProductKey);

line.SetQuantity(2.0);
line = qa.SaveQuoteLine(line);

printLine(line.GetQuoteLineId().toString());
```

## Create from NSProduct

```crmscript! theme={null}
Integer altId = 2;
NSQuoteAgent qa;
NSProduct product = qa.GetProduct(1,"3412-20");

NSQuoteLine line = qa.CreateQuoteLineFromProduct(altId, product);
line.SetQuantity(10.0);
line = qa.SaveQuoteLine(line);

printLine(line.GetQuoteLineId().toString());
```

<Tip>
  Remember to call `SaveQuoteLine()` when you're done building the line!
</Tip>

## Reference

### Frequently used QuoteLine fields

| Field              | Description                          |
| :----------------- | :----------------------------------- |
| quoteline\_id      | ID                                   |
| QuoteAlternativeId | the alternative this line belongs to |
| Name               | product name                         |
| Code               | the product code or article number   |
| Rank               | for sorting                          |

The line will also include **information duplicated from the product** (rather than referenced).

For a complete list of fields, see the [database reference][3].

[3]: ../../../../database/tables/quoteline


## Related topics

- [Create quote](/en/automation/crmscript/howto/quote/create.md)
- [Save Quote Line Configuration](/en/api/reference/restful/agent/quote_agent/save-quote-line-configuration.md)
- [Save Quote Line Configurations](/en/api/reference/restful/agent/quote_agent/save-quote-line-configurations.md)
- [Add alternatives to a quote](/en/sale/learn/quote/add-alternative.md)
- [Adding products to a quote](/en/api/plugins/quote-connectors/adding-products.md)
- [NSQuoteAgent](/en/automation/crmscript/reference/CRMScript.NetServer.NSQuoteAgent.md)
