skyline
skyline

Reputation: 473

How to just update some line item without saving a whole record on NetSuite?

We have a PO with 300 items lines.

And we usually use as follows to save record:

 record.save()

Is it possible to just update the updated fields to new record?

For example, the price of the item in line #10 is changed from 23 to 30, could we just update the value of the item to make the save duration shorter?

Upvotes: 0

Views: 1411

Answers (2)

user1276260
user1276260

Reputation: 31

The good news is that you only need to load the record once, edit and commit as many lines as you want, then save it once.

You can also make a request to a scheduled script to perform the change asynchronously as soon as a processor frees up, OR Use the promise APIs if you're doing this from a client script, to make the delay happen outside of the user interaction.

You're doing Item lines on a PO, so the below stuff is probably not needed, but I'm leaving it here in case it helps someone else:

Any delay in loading or saving is usually caused by workflows and userevent suitescripts deployed to that record type. You can add conditional logic to these scripts and workflows based on a field, cached value, or script deployment parameter if you can afford to skip over what they normally do, and speed things up that way, if needed.

Now, if the sublist in question is comprised of related/child records, then you might need to edit each of these in turn, but can do that with a submit fields API call, one for each record. This may consume more API units than a UserEvent or Suitelet script can do. When there's that many operations to perform, I run a MapReduce and feed it the IDs of all the records I need to process, along with the changes I want to make, or I determine these dynamically within the MapReduce script via search and other logic, or a combination of the two.

If the sublist is the Address Book, then I think you have to load the record that has the addresses, then load the addressbook subrecord, edit and save THAT.

Upvotes: 0

ehcanadian
ehcanadian

Reputation: 1784

To update line items, the record needs to be loaded with record.load and saved with record.save. Body fields can be updated using record.submitFields which doesn't require loading and saving the whole record.

You'll need to continue to load the whole record.

Upvotes: 2

Related Questions