Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

How to empty SysListPanelRelatiTableCallback records once I select next record from the grid

(0) ShareShare
ReportReport
Posted on by 1,873
Hello,
 
I have a form Simple List and Details List grid which display in the left Routes data and customers. Under the  TabPage node I have list of customers left node of listpanel I have Select Customer To Asssign and In the Right Side Assigned customers. Now once I move from the grid next Route lets say Route-A to Route-B the list panel still exists with previous records of Route-A. Please how can I clear/empty listpanel  records once I move next records from the grid. Please have a look my full code below. In below screenshot I want clear the record of Route-B since its belongs to Route-A.
 
 
 
 
[Form]
public class DAWCustSeq extends FormRun
{
    SysListPanelRelationTableCallback    listPanel;
 
    container  unassignedCustomer()
     {
         container assignedCustomer, data;
          DirPartyTable dirPartyTable;
          CustTable custTable;
          DAWCustomerSeqMaster _seqMaster;
        
        while select  dirPartyTable join custTable where custTable.Party == dirPartyTable.RecId && dirPartyTable.RouteID == DAWRoutes_RouteID.valueStr()
        notexists join _seqMaster
          where  _seqMaster.CustAccount == custTable.AccountNum
                  && _seqMaster.Day == WeekDays.valueStr()
         {
         
             data = [custTable.AccountNum,
                    custTable.AccountNum,
                custTable.name()
                    ];
            assignedCustomer +=[data];
         }
         
        return assignedCustomer;
     }
     container assignedCustomer()
     {
         container assignedCustomer, data;
         DirPartyTable dirPartyTable;
         CustTable custTable;
         DAWCustomerSeqMaster _seqMaster;
        
         while select  dirPartyTable join custTable where custTable.Party == dirPartyTable.RecId && dirPartyTable.RouteID == DAWRoutes_RouteID.valueStr()
          exists join _seqMaster
          where  _seqMaster.CustAccount == custTable.AccountNum
               && _seqMaster.Day == WeekDays.valueStr()
         {
         
             data = [custTable.AccountNum,
                    custTable.AccountNum,
                     custTable.name()
                    ];
             assignedCustomer +=[data];
         }
         
         return assignedCustomer;
     }
 
    public void init()
    {
       DAWCustomerSeqMaster _DAWCustomerSeqMaster;
       container columns;
       #ResAppl
       columns = [0,0];
       listPanel = SysListPanelRelationTableCallback::newForm(
       element,
       element.controlId(formControlStr(DAWCustSeq, Customers)), //1
         /Assigned Customers/,//2
        /Select Customers To Assign/,  //3
       #ImageCustomer,//4
       tablenum(DAWCustomerSeqMaster),//5
       fieldnum(DAWCustomerSeqMaster, CustAccount),//6
       fieldnum(DAWCustomerSeqMaster, RouteID),  
       tablenum(DAWCustomerSeqMaster),//8
       fieldnum(DAWCustomerSeqMaster, RouteID),//9
       columns,
       0, //11
       '',//12
       '',//13
       identifierStr(assignedCustomer),//14
       identifierStr(unassignedCustomer));//15
       super();
       listPanel.init();
 
      
    }
    public void refillListPane()
    {
        listPanel.parmRelationRangeValue(DAWCustomerSeqMaster.RouteID); //Route-A
        listPanel.parmRelationRangeRecId(DAWCustomerSeqMaster.RecId);
        listPanel.fill();
    }
    [DataSource]
    class DAWCustomerSeqMaster
    {
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public int active()
        {
            int ret;
    
            ret = super();    
            if(DAWRoutes.RouteID)
            {
                info(DAWRoutes.RouteID);
                element.refillListPane();
            }
            return ret;
        }
        /// <summary>
        ///
        /// </summary>
        public void executeQuery()
        {
            QueryBuildDataSource  queryBuildDataSource;
            queryBuildDataSource = this.query().dataSourceTable(tablenum(DAWCustomerSeqMaster));
            queryBuildDataSource.clearRanges();
            queryBuildDataSource.addRange(fieldnum(DAWCustomerSeqMaster, RouteID)).value(queryValue(WeekDays.valueStr()));
            super();
            }
    }
    [DataSource]
    class DAWRoutes
    {
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public int active()
        {
            int ret;
    
            ret = super();
            if(DAWRoutes.RouteID)
            {
            
                WeekDays.selection(WeekDays::None);
               
            }
    
            return ret;
        }
    }

 
    
    
    
    [Control(/ComboBox/)]
    class WeekDays
    {
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public int selectionChange()
        {
            int ret;
    
            ret = super();
            DAWCustomerSeqMaster_DS.executeQuery();
            
            return ret;
        }
    }
    [Control(/TabPage/)]
    class Customers
    {
        /// <summary>
        ///
        /// </summary>
        public void pageActivated()
        {
            element.refillListPane();
            super();
        }
    }
}
 
 
 
  • Faqruddin Profile Picture
    Faqruddin 1,873 on at
    How to empty SysListPanelRelatiTableCallback records once I select next record from the grid
    Dear Martin,
     
    All your comments below right. Please verify your last reply.

    Thanks
  • Faqruddin Profile Picture
    Faqruddin 1,873 on at
    How to empty SysListPanelRelatiTableCallback records once I select next record from the grid
    Thanks martin. That's really helpful notes. I already noted it. I will check one by one and update you.
  • Martin Dráb Profile Picture
    Martin Dráb 230,853 Most Valuable Professional on at
    How to empty SysListPanelRelatiTableCallback records once I select next record from the grid
    Please explicitly confirm that refillListPane() was called and DAWCustomerSeqMaster.RouteID was Rout-B.
     
    Then debug your callback methods (assignedCustomer() and unassignedCustomer()) and tell us what your debugging revealed.
     
    Also, let me point out to several problems in your code.
     
    Refer to datasource fields, not individual controls. For example, instead of DAWRoutes_RouteID.valueStr(), use simply dawRoutes.RouteID.
     
    Don't store Day as text, because the value is different in different languages. Use an enum instead and compare enum values rather then strings (seqMaster.Day == WeekDays.selection()).
     
    Don't use underscore as a prefix of local variables. That's reserved for method parameters.
  • Faqruddin Profile Picture
    Faqruddin 1,873 on at
    How to empty SysListPanelRelatiTableCallback records once I select next record from the grid
    The issue resides within the refillListPane() function. I aim to reset the values of refillListPane() each time a record switch occurs. The active() function should invoke refillListPane() based on the current data. In the provided code, listPanel is populated based on RoutId and WeekDays for the initial selection of Rout-A. However, upon switching to another record, even though the previous selection's weekday is set to WeekDays::None, the listPanel continues to display the values from the previous selection of Rout-A. I hope this clear.
  • Martin Dráb Profile Picture
    Martin Dráb 230,853 Most Valuable Professional on at
    How to empty SysListPanelRelatiTableCallback records once I select next record from the grid
    If I understand it correctly, you want refillListPane() to reset the values. When you switch records, active() is called and refillListPane() may be called (depending on data). Please tell us whether it gets called in your case. If it does, it means that the problem is inside refillListPane(), right?
  • Faqruddin Profile Picture
    Faqruddin 1,873 on at
    How to empty SysListPanelRelatiTableCallback records once I select next record from the grid
    Thanks Martin. Its look I made long subject. I will try to make next threads short and thank you for correcting. Yes the below code called correctly if there is value exists and listpanel filled. But I have small issue here once I moved to next routid the listpanel still holds the previous selection of routeid. Please I need listpanel to be empty for next routids. 
     
    Thank you.
     
    if(DAWRoutes.RouteID)
                {
                    info(DAWRoutes.RouteID);
                    element.refillListPane();
                }
     
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,853 Most Valuable Professional on at
    How to empty SysListPanelRelatiTableCallback records once I select next record from the grid
    I believe you already know how to run code when selecting a record in grid (using active() method, as discussed in your previous thread), therefore this is not what you want to ask about, right? We can reduce the question to "How to empty SysListPanelRelatiTableCallback". Am I correct?
     
    I see you call refillListPane() when activating the record, if dawRoutes.RouteID has a value. Please tell us whether refillListPane() is called but not implemented correctly or whether it's not called at all in your case. Use the debugger if you don't know what happens there.
     
    Next time, please remove code irrelevant to the question. It will make it easier to follow and to focus on the right problem.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans