I'm setting the value for a select field that has ...
# suitescript
a
I'm setting the value for a select field that has been added before load, but it will not fire fieldchanged, any idea how to fix this?
s
Client script would not do anything before the page loads, that would be expected. Take whatever logic you have on fieldChanged and share it between the UE and client. Or take the logic on the fieldChanged and share between pageInit in the client
a
The logic is in fieldchanged client side
That's the issue
@Sandii if user changes the value for field A, script will set the value for field B, here I want to fire fieldchanged for field B
s
right that cant happen beforeLoad, so either create a shared function and set the new field value in pageInit if the first field is set, or manually do whatever the client is doing in beforeLoad when you set the field value
a
There is no beforeLoad
s
you just said you are setting the value in beforeLoad
a
I've just said that the field has been added to the form
beforeLoad
Value will be set by user
Client side
s
I dont understand the issue
Adding a field via beforeLoad works fine, fieldChanged does get fired on fields that were added beforeLoad, so what is the problem
a
@Sandii Field B is a select field and has been added before load. User will change field A and it will fire fieldchanged for field A, inside that fieldchanged event I will set the options for field B and set the isSelected to true for one of the options, but it will not fire fieldchanged for field B.
s
fieldChanged can chain, it will fire when field B changes if you tell it to
a
That's the issue
It will not here
e
Try
postSourcing
on Field B instead
a
I've test that as well
Didn't work
If the user select an option for field B everything is ok
But when the value will set by fieldchanged event for field A it will not fire the event
s
Are you setting the value with the
isSelected
parameter
or setting the value with setValue
a
is selected
s
thats the problem
its not a user action setting the value
set the value with setValue
a
Thanks
s
you could also fire the logic that is supposed to happen when you set that value when you set field one with a shared function