I am replacing a required standard field on a reco...
# suitescript
d
I am replacing a required standard field on a record with one of my own with filtered values and at the end I need to put the value from the scripted field back into the standard field. I thought about comparing the values in a beforeSubmit in the UE, but there is client-side validation in NS that is saying the field is required and that seems to fire before it even lets the user event get to the beforeSubmit trigger.
e
if you are creating the custpage on the fly, I think it will not get triggered. You might need to create it as a regular custom field.
d
I don't think I can remove select options from a regular custom field though, right/
as it stands, I'm using insertSelectOption to control what comes up in the select field
I think that only works on fields created on the fly, right?
s
I would recommend keeping that logic client side since it sounds like you're doing it specifically as a facade to the behind-the-scenes native field?
i.e. copy your custom field back to the related native field before saving the record. A user event should never even need to know that a temporary surrogate field existed.
d
@stallbert Yeah, I tried to do that in the client side saveRecord step but apparently NetSuite's inbuilt standard field validation fires before saveRecord does. So when I copy the field back over in saveRecord, I still get a validation error that the field is null.
s
do it on field change. That is, whenever someone changes your surrogate field, immediately mirror it to the native field. that's usually what you want anyway, so that any sourcing or other otherwise native behavior is still engaged at the right moment.
l
@stalbert That is what I was about to say. Client Script on Field Change should do it. This way you are setting the value of the field before saving and therefore the default NS field should be 'valid' before save.