Maixant
Maixant

Reputation: 81

Update a field with display method

I have a form with 2 fields, the 1st is filled with a lookup and the 2nd (not editable, just a Description of the 1st) is filled with a "display" method in the form.

public display Name displaySalesChannelName()
{
    return SalesChannelTable::find(SalesChannelFilter.valueStr()).Description;
}

Seems to work fine, but only shows the value when the field is clicked.

How can I synchronize this 2 fields?

Upvotes: 0

Views: 4229

Answers (2)

10p
10p

Reputation: 6706

You can override method modified of the 1st control (with the lookup) and call method update of the 2nd control from there, e.g. if the name of the 2nd control is SalesChannelName and its AutoDeclaration property has been set to Yes, then:

public boolean modified()
{
    boolean ret = super();

    SalesChannelName.update();

    return ret;
}

But then there's not much sense in using a display method here. You can just as well clear the DataMethod property of the 2nd control, and the modified method above can be rewritten as follows:

public boolean modified()
{
    boolean ret = super();

    SalesChannelName.text(SalesChannelTable::find(this.valueStr()).Description);

    return ret;
}

Upvotes: 1

Thomas Post
Thomas Post

Reputation: 535

you should try to put the display method on table level, your field's properties in the form must have the datasource Table name as datasource and your method's name as data method

Upvotes: 1

Related Questions