Create form - pulling data on related field selection

Hi,

I’m tried to get the following:

When selecting a product, the following fields need to be filled:

image

Should i use fieldvaluechange event of valuechange event?

kr

Tim

Use ValueChangeEvent.
This event is called when the user has finished selecting the instance.
This is what is required in your scenario.
The FieldValueChangeEvent event is used to preprocess the user’s manual input. An entity from the data model has not yet been defined here.

2 Likes

Hi, thanks for the information; based on this, i came up with the following in the

public class LicenseEdit extends StandardEditor<License>

And the code itself to get the object of the data presented in the form (you need to use this.getEditedEntity()) both for new and existing data

@Subscribe("productfkidField")
public void onProductfkidFieldValueChange(HasValue.ValueChangeEvent<Product> event) {

    this.getEditedEntity().setPrefix(event.getValue().getPrefix());
    this.getEditedEntity().setSubfix(event.getValue().getSubfix());

    this.getEditedEntity().setExternalid(UUID.randomUUID().toString());

    this.getEditedEntity().setCode(this.getEditedEntity().getPrefix());

}
1 Like