ExploreConsulting / netsuite-fasttrack-toolkit-ss2

NFT for SuiteScript 2.X
75 stars 20 forks source link

add support for `ignoreFieldChange` behavior in dynamic mode #38

Closed ShawnTalbert closed 3 years ago

ShawnTalbert commented 4 years ago

Currently there is no way to include the ignoreFieldChange option when working with sublist fields in dynamic mode. Depending on what updates a user does and what code exists, this can cause an infinite loop of fieldChanged events. Our current workaround is to just _.debounce the fieldChanged entrypoint.

so I'm not sure if we really need it, but one option could be to add a ignoreFieldChange property to the Sublist class so an end user could toggle it on or off. Usually if you want this on when working in dynamic mode on a sublist you want it one for all your operations. So a use case my look like this


function fieldChanged(ctx) {
  const so = new SalesOrder(ctx.newRecord)
  so.item.ignoreFieldChange = true
  _.forEach(so.item, line => {
    line.field1 = 1
   line.field2 = 'hello'
   line.field3 = 'world'
})
so.item.ignoreFieldChange = false // optional in this case since we're setting it `true` on entry to this function
}