How to access value of a gui component of one screen in another screen

Hi,
How can I access the selected value of a lookup field component of one screen in another screen?

For example, I have a lookup field for transaction date in screen1.xml.

<lookupField id="LUFTransactionDate" caption="Transaction Date Column" optionsContainer="transactionDateDc" captionProperty="transactionDate" dataContainer="transactionDateId" property="transactionDate"/>

I want to access the selected value of this lookup field in screen2.java class. How can I do that?

Thanks,
Renuka

Hello @renuka.venugopal01

First of all you should create a method that will provide lookup field value:

// in screen1
// "EntityType" - type of entity stored in options datasource
public EntityType getLUFTransactionDate() {
  return LUFTransactionDate.getValue();
}

Then get a reference to the screen1 via OpenedScreens:

// in screen2

@Inject
private Screens screens;

private void foo() {
    screens.getOpenedScreens()
        .getWorkAreaScreens()
        .stream()
        .filter(screen -> screen instanceof Screen1Controller)
        .findFirst()
        .ifPresent(screen -> screen.getLUFTransactionDate());
}

Regards,
Daniil

Thank you. I got it working now.