web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

selectionChange() not working as expected

(0) ShareShare
ReportReport
Posted on by 1,883
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;
}
 
 
 
I have the same question (0)
  • Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at
    First of all, let me make your code easier to read. I see that most of it is commented out and it can be simplified a bit.
     
    RoutMaster_1 data source:
    public void executeQuery()
    {
        QueryBuildDataSource qbds = this.queryBuildDataSource());
        qbds.clearRanges();
        qbds.addRange(fieldnum(RoutMaster, WeekDays)).value(queryValue(RoutMaster_1_WeekDays.selection()));
    
        super();
    }
    Combo Box:
    public int selectionChange()
    {
        int ret = super();
    
        RouteData_1_DS.executeQuery();
        
        return ret;
    }
    The error you mentioned is related to saving, not filtering. What is its stack trace?
     
    By the way, the name of RoutMaster_1_WeekDays control suggests that it's a control bound to WeekDays field of RoutMaster_1 data source. If it's unbound, as you mentioned, you should change the name to avoid confusion.
  • Verified answer
    Faqruddin Profile Picture
    1,883 on at
    Its unbound control. The issue has been solved recompile the project.
     
    Thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans