Hi all, does anyone know if it is possible to incr...
# suitescript
n
Hi all, does anyone know if it is possible to increment a numeric field using
record.submitFields
without querying the record first?
I would like to use a formula or something like:
Copy code
record.submitFields({
  type: DROPSHIP_INVENTORY_TYPE,
  id,
  values: {
    custrecord_qc: '${custrecord_qc} + 1',
  },
  options: {
    enableSourcing: false,
    ignoreMandatoryFields: true,
  },
});
c
No, you need to submit the actual value.
n
I'm trying to make it atomic, is there anyway to wrap the get and submit in a transaction?
c
just do a lookup prior to the submit. Its fast and doesn't take hardly any governance. The other way would be to set a flag or something on the record since submitFields fires the UE you should be able to capture the flag and increment in another script if you must.
b
actually load the record and save it
netsuite will throw an error if something else modifies the record between when you load and save it
c
that too
b
Use Optimistic Locking if you are working with a custom record
1
n
Thanks