I got one more question. I am trying to see if a ...
# suitescript
p
I got one more question. I am trying to see if a field value changed on a form. do you know why the following if statement does not work
b
be more specific about what you mean by not working
if you mean the statement for the if condition does not run you need to share the values in your variables
p
I have a multi-select field that I am trying to see if the values changed and it keeps on running through the if statement even though the subsidiary did not change
departmentsubchange.js
I included the code
b
and what are the values for oldStatus and newStatus
p
Copy code
{
  "details": "newStatus = 10 Ping Identity Corporation"
}
Copy code
{
  "details": "oldStatus = 10 Ping Identity Corporation"
}
b
are you sure that is the value
i would have expected internal id numbers from your code
p
I use gettext instead of getvalue
yes thats what the debugger is returning
the script keeps on running the if condition even if nothing has changed
b
more sense
getValue for a multi select field returns an Array
p
what would be the best way to compare the two arrays?
b
oldStatus and newStatus are different Arrays despite having the same values for their elements
lazy way is just convert it to a string using .toString and compare the string values
it relies on netsuite returning the multi select values in the same order
👍 1
p
got it
let me try that
thank you
b
you may also want to move the script to beforeSubmit so you dont resave the department
p
ok and it worked with the aftersubmit
thanks for your help