---
title: Line Items Fields
slug: netsuite/line-items-fields
description: Learn how to populate line items in Breadwinner's Sales Order from custom objects using a Custom URL Structure. This document provides step-by-step instructions on specifying child objects and their fields, ordering line items, and populating custom field
docTags: 
createdAt: 2021-10-30T07:00:51.000Z
---

# Populating Line Items from Child Records

It is possible for Breadwinner to populate all of the Line Items of the Sales Order from custom objects, provided a Custom URL Structure is used.

This requires two things: specifying the child object and specifying the fields on that child object to use.

You may iterate over only one Child Object, i.e. you must pick one and only one Related List to iterate over, not two or more related lists. And, as of now, we do not have the ability to iterate over a subset of those child records; you must iterate over all of them or none of them.

## Specifying the Child Object

Please note, *we do not use the API name of the object, we use the Child Relationship Name.* This is because sometimes you will have multiple lookup fields from the child to the parent record, and we won’t know which one to use. Thus, you must specify the child object by using the Child Relationship Name.

The Child Relationship Name can be tricky to find. In setup, go to the child object, and click on the name of the lookup field (or master/child field) to the parent object. If you have two or more lookup fields to the same parent object, make sure you select the right one. After clicking the name of the lookup field to the parent object, you will be on the setup page of that field.

You will see the Child Relationship Name field. We recommend you append “\_\_r” to that field, as this is best practice, but this is optional because we will append that transparently if it is missing.

:::CodeblockTabs
Button URL

```css
&child_relationship_name=child_name__r
```
:::

## Specifying the Child Object Fields

As well as specifying the Child Object, you must specify fields on that Child Object. Most fields are optional, but NetSuite requires an Item in every line item.

Also, please note that the field types must match. Item field will need either a direct lookup to NetSuite Item (either via a lookup or master/detail) or a formula field with the NetSuite Item Salesforce Record Id. Quantity and Rate are number fields.

:::CodeblockTabs
Button URL&#x20;

```css
&co_netsuite_item=netsuite_item_field__c
&co_description=description_field__c
&co_quantity=quantity_field__c
&co_rate=rate_field__c
&co_sort_by=sort_field__c
&co_department=department_field__c
&co_class=class_field__c
```
:::

## Ordering the Line Items

You can fetch the child records in a particular order and send them to NetSuite in the same order. This can be referenced by another field on the child object:

:::CodeblockTabs
Button URL

```css
&co_sort_by=sort_field__c
```
:::

## Department

This can be referenced either via another field on the originating object or as a text field in the formula. So you may use either approach:

:::CodeblockTabs
Button URL (Field Value)

```css
&co_department=dept_api_field__c
```

Button URL (Static Value)

```none
&co_department=123
```
:::

## Class

This can be referenced either via another field on the originating object or as a text field in the formula. So you may use either approach:

:::CodeblockTabs
Button URL (Field Value)

```css
&co_class=class_api_field__c
```

Button URL (Static Value)

```none
&co_class=123
```
:::

## Populating Custom Line Item Fields

We designate a custom field on a line item by starting the line of the Custom URL as **\&co\_cf,&#x20;**&#x77;hich is followed by the **orderNumber (optional)&#x20;**&#x61;nd then th&#x65;**&#x20;type** of the custom field (i.e. text, date, etc.) followed by the API name of the NetSuite field. Here is the theoretical construction.

:::CodeblockTabs
Button URL (Field Value)

```none
&co_cf_type_netsuite_api_name=formula_field__c
```

Button URL (Static Value)

```none
&co_cf_type_netsuite_api_name=123
```
:::

### Add "type" (Required)

The **type** can be decided by checking the **NetSuite Field Type&#x20;**&#x6F;f the line-level custom fields. For more information, please refer to [Custom Fields](docId\:SLAOaVMc9hGhpwuvjK-2w)

| **NetSuite Field Type** | **Type Value** | **Example**                                                           |
| ----------------------- | -------------- | --------------------------------------------------------------------- |
| Date                    | date           | \&co\_cf\_***date***\_netsuite\_api\_name=formula\_field\_\_c         |
| Datetime                | datetime       | \&co\_cf\_***datetime***\_netsuite\_api\_name=formula\_field\_\_c     |
| List Record (Lookup)    | picklist       | \&co\_cf\_***picklist***\_netsuite\_api\_name=formula\_field\_\_c     |
| Integer Number          | integer        | \&co\_cf\_***integer***\_netsuite\_api\_name=formula\_field\_\_c      |
| Decimal Number          | number         | \&co\_cf\_***number***\_netsuite\_api\_name=formula\_field\_\_c       |
| Currency                | number         | \&co\_cf\_***number***\_netsuite\_api\_name=formula\_field\_\_c       |
| Percent                 | number         | \&co\_cf\_***number***\_netsuite\_api\_name=formula\_field\_\_c       |
| Check Box               | checkbox       | \&co\_cf\_***checkbox***\_netsuite\_api\_name=formula\_field\_\_c     |
| Free Form Text          | text           | \&co\_cf\_***text***\_netsuite\_api\_name=formula\_field\_\_c         |
| Text Area               | textarea       | \&co\_cf\_***textarea***\_netsuite\_api\_name=formula\_field\_\_c     |
| Long Text               | longtextarea   | \&co\_cf\_***longtextarea***\_netsuite\_api\_name=formula\_field\_\_c |
| Email Address           | text           | \&co\_cf\_***text***\_netsuite\_api\_name=formula\_field\_\_c         |
| Hyperlink               | text           | \&co\_cf\_***text***\_netsuite\_api\_name=formula\_field\_\_c<br />   |

### Add "orderNumber" (Optional)

:::CodeblockTabs
Button URL (Field Value)

```none
&co_cf_orderNumber_type_netsuite_api_name=formula_field__c
```
:::

Th&#x65;**&#x20;order number** part in the button URL syntax above determines the order in which the custom fields are displayed in the columns of the line item table.

If we have an order number, they will be displayed as per our preferences:

:::CodeblockTabs
Button URL (Field Value)

```none
&co_cf_02_date_custcol_endDate=formula_field__c
&co_cf_01_date_custcol_startDate=formula_field__c
```
:::

![](https://api.archbee.com/api/optimize/amOMwpmEgToJSqhaSTxXr/SwByrOGn9ltewV5eOgCCk_order2.png)

If no order is given, the custom field columns are added randomly or alphabetically:

:::CodeblockTabs
Button URL (Field Value)

```none
&co_cf_date_custcol_endDate=formula_field__c
&co_cf_date_custcol_startDate=formula_field__c
```
:::

![](https://api.archbee.com/api/optimize/amOMwpmEgToJSqhaSTxXr/vKl5XCt1R1RQTW-VSHB_Y_order1.png)

Note: You can have a mixture of ordered and non-ordered custom fields. The non-ordered ones will appear at the end.

# Populating Line Items from Originating Record Fields

You may have a number of fields on the Originating Record that you wish to populate various line items on the Sales Order/Purchase Order/Bill. This is possible, as long as you specify each and every individual line. This is different from populating child records, where we iterate over each child record. Here, you specify the number of lines in each URL.

The Sales Order/Purchase Order/Bill URL will start the same as always, with the structure taken from the basic Custom URL structure for Sales Order/Purchase Order/Bill fields, where you can specify dates, etc.

However, the URL will then specify line items, using the structure \&line#\_field=*your\_field\_\_c*

:::CodeblockTabs
Button URL

```css
&line1_netsuite_item=netsuite_item_field__c 
&line1_description=description_field__c
&line1_quantity=quantity_field__c
&line1_rate=rate_field__c
&line1_department=department_field__c
&line1_class=class_field__c
&line1_location_id=location_field__c
&testing=true
```
:::

*Internet Explorer, depending on the version, may have a limit of 2000 characters in the URL. Firefox and Chrome have potentially much longer URL limits, of 30,000 characters and up. Salesforce may have it's own limits. We cannot be responsible for either your browser’s URL character limitation or Salesforce’s URL character limitation. As such, we recommend this approach for just a few lines, however, it may work for dozens of lines or more.*

### Specifying more than one line

Should you want more than one line, you simply need to start with \&line2… and so forth.

:::CodeblockTabs
Button URL

```css
&line1_netsuite_item=netsuite_item_field__c
&line1_quantity=quantity_field__c
&line1_rate=rate_field__c
&line2_netsuite_item=netsuite_item_field__c
&line2_quantity=quantity_field__c          
&line2_rate=rate_field__c
&line3_netsuite_item=netsuite_item_field__c
&line3_quantity=quantity_field__c
&line3_rate=rate_field__c
```
:::






