Hi I am using D365FO.
I have a lookup string edit control which is initially blank. However the corresponding grid is already populated with all the other fields. I need to clear the grid initially since there is no value in the lookup control. How do I accomplish this?
Form has table A as datasource. Lookup is query from Table A column 1. Grid should contain column 2, 3, 4 of Table A.
I have one table
Table Room
Columns: RoomNumber, Name, Gender
I have a lookup string edit control which is initially blank. I have overridden the lookup method to use query referencing field RoomNumber. I have the form using Table Room as datasource…
How do I make it so that selection of RoomNumber in lookup populates the grid with Name,Gender records that have RoomNumber = lookup.
Also there are so many records so the initial lookup control value is blank, and grid should be blank too.
so far I have the ff:
[Form]
public class Test extends FormRun
{
QueryBuildRange range;
boolean started = true;
public void init()
{
super();
Room_ds.reread();
}
[DataSource]
class Room
{
///
/// Datasource for the form prepares the query
///
public void init()
{
super();
range = this.query().dataSourceNo(1).addRange(fieldNum(Room,Name));
}
///
/// filters the query based on value of the lookup
///
public void executeQuery()
{
range.value(filterControl.valueStr());
started = false;
this.queryRun();
super();
}
}
[Control(“String”)]
class filterControl
{
///
/// creates a query for the lookup
///
public void lookup()
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(Room), this);
sysTableLookup.addLookupField(fieldNum(Room, Name));
queryBuildDataSource = query.addDataSource(tableNum(Room));
queryBuildDataSource.addGroupByField(fieldNum(Room,Name));
queryBuildDataSource.orderMode(OrderMode::GroupBy);
queryBuildDataSource.addSortField(fieldNum(Room,Name));
SysTableLookup.parmUseLookupValue(false);
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
//super();
}
///
/// when user selects lookup, refresh the values in the grid
///
///
public boolean modified()
{
boolean ret;
ret = super();
Room_ds.executeQuery();
return ret;
}
}
}