Sending parameter to browser screen through lookup

How can we pass a parameter to the browser screen when opened via LookupPicker field?

I have two screens and both of them have customer lookupPicker field. When I lookup customer customer.browser screen is displayed which is very much default in CUBA. Now I want to filter the SQL of customer.browser for which the parameter is passed from the screen calling it. I didn’t find any option to pass such parameter unless I am missing something. Thanks in advance.

Hi!

To pass parameters to Lookup Screen you can use setLookupScreenParams in PickerField.LookupAction.

For instance, in Edit Screen:

@Named("fieldGroup.city")
protected PickerField cityField;
...
PickerField.LookupAction lookupAction = cityField.getLookupAction();
lookupAction.setLookupScreenParams(ParamsMap.of("param", "paramValue"));

And in Lookup Screen:

@Override
public void init(Map<String, Object> params) {
    String param = (String) params.get("param");
}

Or you can do following in Lookup Screen:

@WindowParam(name = "param")
protected String string;

@Override
public void init(Map<String, Object> params) {
    showNotification(string);
}

Also, check these links:
How to use your parameter in a query, see documentation.
About @WindowParam annotation in the documentation.
Also, you can read about CreateAction and EditAction, because they provide setWindowParams method, see documentation.

1 Like