scriptContext.fieldId
# suitescript
n
scriptContext.fieldId
s
Nah. that will tell me the current field. I need to know if, for example, the item selected caused the department to change
So if the item is selected, the dept automatically changes. I need to know if the item value changed, if it did, empty out the department
k
yeah so wouldn't it be
if (context.fieldid === 'item') { empty the department field }
s
The item fires and then the department fires, so at the point that the item is changed, the department has yet to receive a value
k
could put some more on the if
s
whatcya mean by put some more?
k
if
(context.fieldid === 'item' && context.fieldid === 'department')
{ empty the department field }
i'm sure i have done that before.
s
it can't be both though at the same time
k
that's true
hmmmm
This is on a client??
Maybe store the item value when record loads and then use that to compare.
sorry just spitballing here.
s
no worries. That's what I had, but this is going to be dynamic so I'm going to need to do it for multiple
what I may be able to do is add it to an array object and keep a comparison. Then when the right pair matches up, set a "need to be empty" flag to true. Then once the dept is emptied, set it back to false
k
yeah that has just made me fry my mind.
w
You could insert the logic into the postSourcing field, as this would fire for the Department field but only when it is being set by something else (in this case the item field)
If Department can be set by anything else then you’d perhaps want to include a boolean that gets set to true when item field is picked and back to false after your department has cleared, and only change department if the boolean is true