Question: There is a customized transaction line field which is named as "custcol\_so\_line\_id". Its value should be the same as the ID of the sublist line.

The code is as follows:

```
function beforeSubmit(context) {

    var rec = context.newRecord;

    var lineItemID = rec.getSublistValue({
        sublistId: 'item',
        fieldId: 'id',
        line: 1
    });

    rec.setSublistValue({
        sublistId: 'item',
        fieldId: 'custcol_so_line_id',
        value: lineItemID
    });
}

return {
    beforeSubmit: beforeSubmit
}

```

After clicked the **Save** button in Sales Record. The sales record should display **SO\_12345** in the customized line field "cuscol\_so\_line\_id". But it didn't and shows the error as follows:
`load: Missing a required argument: id` for the code `var salesRec = record.load({...`

If I change the entry point to "afterSubmit", then the **SO\_12345** appears.

Can't we update the record before it is submitted? How to find the id for line in `beforeSubmit` function?

Answer: 
What you're trying to get with `salesRec` is the same as what you already have with `rec`. However, you cannot load `salesRec`, as that has not been written to the database at the point when `beforeSubmit` is fired. You need to make the changes to `rec` instead.

```
function beforeSubmit(context) {

    var rec = context.newRecord;

    rec.setSublistValue({
        sublistId: 'item',
        fieldId: 'custcol_so_line_id',
        value: 'SO_12345',
        line: 1
    });
}

return {
    beforeSubmit: beforeSubmit
}

```
I found the URL is as this
`(domain).netsuite.com/app/accounting/transactions/salesord.nl?whence=` which there is no sales record id inside.

Does that mean the ID for record is not generated?
If yes, then the line id maybe not defined yet as well since its prefix will **RECORD-ID\_LINE-INDEX**, e.g. `2100627_2`, which `2100627` is the record ID and `2` is the line index.