How can I check if a field exists before a functio...
# suitescript
p
How can I check if a field exists before a function is fired?
n
Depends on the context but you could use N/record and record.load, or you could use currentRecord.. and use .getFields() to get all fields on the record to see if the one you need exists.
p
so what I am trying to do is hide fields based on a selection made in another field. These fields exists on some custom sales order forms but not others. So if the field is not shown in that form an error pop's us that says TypeError Cannot set property 'isDisplay' of null.
m
null check your field before setting the isDisplay property. if(myfield !== null) myfield.isDisplay = false;
👍 3
p
thanks!