I have 3 checkboxes on an item. I have a map reduc...
# suitescript
n
I have 3 checkboxes on an item. I have a map reduce that processes a variety of item data. I need to uncheck a different checkbox based on a parameter. The parameter is used to look up the field id of the field that needs un-setting. So my code looks like this for un-setting the checkbox and I know the "uncheckField" variable has the correct field id.
Copy code
let id = record.submitFields({
  type: record.Type.INVENTORY_ITEM,
  id: itemID,
  values:{ 
    uncheckField: false
  },
  options: {
    enableSourcing: false,
    ignoreMandatoryFields: true
  }
});
uncheckField holds the correct field name. Using the fieldname directly unchecks the checkbox. The .submitFields call returns the item internalid as expected, does not error but also does not uncheck the checkbox, Is it not possible to substitute out the "values" field name key in this way? (I've tried backticking and ${uncheckField} and that just breaks it)
OK figured it 🤦🏻‍♂️
Copy code
let id = record.submitFields({
  type: record.Type.INVENTORY_ITEM,
  id: itemID,
  values:{ 
    [uncheckField]: false
  },
  options: {
    enableSourcing: false,
    ignoreMandatoryFields: true
  }
});
duh. Leaving for anyone else it might be useful for.
3
e
For further future reference, it's the square brackets
[uncheckField]
that fixed the issue. This is a computed property name
🙌🏻 1