Really struggling with something. I have a custom...
# suitescript
m
Really struggling with something. I have a custom record with several custom fields. The fields are filtered by a List/Record, Item custom field. I need to perform some logic on the fieldChanged Event for this main List/Record Item field, then some different logic on the fieldChanged events for the "filtered down" fields on the form. However, when I change the main List/Record field, the event is firing for all the "filtered down" fields. Hope that makes sense. I have tried the postSourcing Entry point as well. I am assuming this is because of the filtering, but is there any way to get around this?
b
its essentially mandatory that fieldChanged entry points have logic to return early if the fieldId in the context is not the one you want to run on
similarly, if you want your fieldChanged to do different things for different fields, then you need to have some if statements to created different branches of code
s
I could be getting you totally wrong, but it looks like you need to get the field from the context and limit it so that your code only runs when the field is the main List/Record field?
m
right. Thought I was doing that with my if() statement.
if(currentField === 'custrecord_config_base_unit'){
//logic
}
if(currentField === 'custrecord_config_strobe_light' ||
      
currentField === 'custrecord_config_blue_light' ||
      
currentField === 'custrecord_config_hitch_select' ||
      
currentField === 'custrecord_config_shelving' ||
      
currentField === 'custrecord_config_side_rails' ||
      
currentField === 'custrecord_config_netting' ||
      
currentField === 'custrecord_config_rear_basket'){
//logic
}
s
then it might depend on your //logic part, if you're setting values you need to use ignoreFieldChanged = true so it doesn't reloop it self this is one of those setValue options if you like
t
also you might want to put some additional guard like
runtime.ContextType.USER_INTERFACE context.type.create/edit