> ## 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.

# Price lists

> How to work with price lists in CRMScript.

## Retrieve price lists

### NSPriceList GetPriceList(Integer priceListId)

Fetch a specific price list by its ID.

```crmscript! theme={null}
NSQuoteAgent qa;

NSPriceList priceList = qa.GetPriceList(2);

printLine(priceList.GetName() + ": " + priceList.GetCurrency());
```

### Get multiple price lists from quote connection

You've got several variants of `GetPriceList()`, which all return `NSPriceList[]` and take the **ID of a quote connection** as the 1st argument.

| Method                          | Currency     | Only active | Include upcoming/expired |
| :------------------------------ | :----------- | :---------: | :----------------------: |
| GetActivePriceLists             | String       |      x      |                          |
| GetActivePriceListsByCurrencyId | Integer (ID) |      x      |                          |
| GetAllPriceLists                | String       |             |             x            |
| GetAllPriceListsByCurrencyId    | Integer (ID) |             |             x            |

```crmscript! theme={null}
NSQuoteAgent qa;

NSPriceList[] priceLists = qa.GetActivePriceLists(1, "NOK");

for(Integer i = 0; i < priceLists.length(); i++) {
  printLine(priceLists[i].GetName());
}
```

## Create price list

```crmscript! theme={null}
DateTime now;
NSQuoteAgent qa;

NSPriceList priceList = qa.CreateDefaultPriceList();

priceList.SetName("gardening tools fall 2020");
priceList.SetValidFrom(now);
priceList.SetValidTo(now.moveToYearEnd());

priceList = qa.SavePriceList(priceList);

printLine(priceList.GetPriceListId().toString());
```

<Tip>
  By default, the new price list will be valid "forever", with the validity period set using the max and min value of the DateTime type.
</Tip>

## Update price list

1. Fetch the NSPriceList object with the agent.
2. Call the appropriate *set* methods.
3. Call `SavePriceList()`.

## Delete price list

```crmscript theme={null}
Integer priceListId = 99;
NSQuoteAgent qa;
qa.DeletePriceList(priceListId);
```

## Reference

### Frequently used price list fields

| Field         | Description                                      |
| :------------ | :----------------------------------------------- |
| pricelist\_id | ID                                               |
| Name          | Label for UI                                     |
| Description   |                                                  |
| CurrencyId    | The currency of the list                         |
| ValidFrom     | The date at which the list becomes valid         |
| ValidTo       | The last date the list is valid                  |
| IsActive      | Link to product information web page             |
| IsERPCopy     | Whether it's a cache and can't be changed in CRM |

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

[2]: ../../../../database/tables/pricelist


## Related topics

- [PriceList](/en/api/archive-providers/reference/pricelist.md)
- [NSPriceList](/en/automation/crmscript/reference/CRMScript.NetServer.NSPriceList.md)
- [Delete Price List](/en/api/reference/restful/rest/list_price/delete-price-list.md)
- [Get Price List](/en/api/reference/restful/rest/list_price/get-price-list.md)
- [Post Price List](/en/api/reference/restful/rest/list_price/post-price-list.md)
- [Default Price List](/en/api/reference/restful/rest/list_price/default-price-list.md)
