Dears,
I have a basic simplelist form with a query as its data source, which includes two data tables with a common relation. My goal is to filter the grid using the bound controller WeekDays. Initially, it filters the records as expected. However, when I reload the form for the second time and try to filter, it throws an error: /Cannot create a record in RouteData (RouteData). The record already exists. I am puzzled as to why the selectionChange() function is not working as expected. Kindly review my code and provide insights.
Form Class :
QueryBuildRange qrWeek;
RoutMaster routMaster;
Form init():
public void init()
{
super();
// routMaster = element.args().record();
// Day.selection(WeekDays::Sunday);
// info(strFmt(/Day %1/,Day.valueStr()));
}
FormDataSource
public void executeQuery()
{
QueryBuildDataSource queryBuildDataSource;
queryBuildDataSource = this.query().dataSourceTable(tablenum(RoutMaster));
queryBuildDataSource.clearRanges();
queryBuildDataSource.addRange(fieldnum(RoutMaster, WeekDays)).value(queryValue(RoutMaster_1_WeekDays.selection()));
super();
/* qrWeek = SysQuery::findOrCreateRange(this.query().dataSourceTable(tableNum(RoutMaster)), fieldNum(RoutMaster, WeekDays));
if(RoutMaster_1_WeekDays.selection())
{
qrWeek.value(int2str(RoutMaster_1_WeekDays.selection()));
}
else
{
qrWeek.value(SysQuery::valueUnlimited());
}
super();*/
}
Combo Box:
public int selectionChange()
{
int ret;
ret = super();
RouteData_1_DS.executeQuery();
return ret;
}