When to use Temporary State vs. local variables

tempState.setValue() is a promise so you never know when it will actually be set.
So do not use them as variable replacements within a js query. You may need to set a temp var within a js query, but do not use it again within the same code. You will need to put the value into a local variable if you intend on using it again later on. For instance.

// set currentCustomer to use somewhere else in the app
// set the value to a local var if you need to save its scope here.
const customer = tblTemplatesModal.selectedRow.data.customer_id

  additionalScope: {
	// now you can use the variable here. If you use 
	// currentCustomer.value here it may not yet be set.
      customerId:  customer

(from @bradlymathews)

1 Like

Very helpful. This should make its way into the docs IMO.

1 Like