Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How to call more than two fields in SysListPanelRelationTableCallback

Posted on by 1,869
Hello,
 
I have simple list and details grid form. Inside the form I created the TabPage its control available customers and drop the values of available customers to right side in not available customers custom table called DAWCustomerSeqMaster. Everything works well and its created customer account and RouteID in DAWCustomerSeqMaster. But In DAWCustomerSeqMaster I have one more field called Day and I need to take the value from my comboBox.valuestr() and fill in to related table DAWCustomerSeqMaster. Below is my code for SysListPanelRelationTableCallback. I need one more column   after fieldnum(DAWCustomerSeqMaster, RouteID) to take value from comboBox.valuestr(). Please advice.
 
 public void init()
    {
       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();
    }
  • Faqruddin Profile Picture
    Faqruddin 1,869 on at
    How to call more than two fields in SysListPanelRelationTableCallback
    Hi Waed,
     
    Yes I try this approach last two days ago. But the record is not created in DAWCustomerSeqMaster.Day. I try also DataSourceEventHandler.Written and its same. I need additional business logic to play after records inserted into DAWCustomerSeqMaster using listPanel. Please have a look below code as well.
       [FormDataSourceEventHandler(formDataSourceStr(DAWCustSeq, DAWCustomerSeqMaster), FormDataSourceEventType::Written)]
        public static void DAWCustomerSeqMaster_OnWritten(FormDataSource sender, FormDataSourceEventArgs e)
        {
            FormRun                 form           = sender.formRun();
            FormDataSource         DAWCustomerSeqMaster_ds =       form.dataSource(formDataSourceStr(DAWCustSeq,DAWCustomerSeqMaster)) as FormDataSource;
            DAWCustomerSeqMaster             _dawCustBuffer    = DAWCustomerSeqMaster_ds.cursor();
           
            if(_dawCustBuffer.RecId)
            {
                //do something
            }
        }
     
     
     
     
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 6,195 Super User 2024 Season 2 on at
    How to call more than two fields in SysListPanelRelationTableCallback
     
    You can right click on your datasource for  DAWCustomerSeqMaster table, override write method and add this code:
     
    
    public void write()
    {
      super();
    
      DAWCustomerSeqMaster.Day =  YourComboBox.selection();
    }
    
     Give it a try and let me know if you still need help.
     
     
    Thanks.
    Waed Ayyad
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Faqruddin Profile Picture
    Faqruddin 1,869 on at
    How to call more than two fields in SysListPanelRelationTableCallback
    How can I set combo box field on the Write() method. I know validateWrite(). Can I have snippet of the code for write().
     
    Thank you.
  • Waed Ayyad Profile Picture
    Waed Ayyad 6,195 Super User 2024 Season 2 on at
    How to call more than two fields in SysListPanelRelationTableCallback
    Hi Faqru,
     
    Did you try to override the button that move the record from the left grid to the right grid and add the code that set the day of week field there?
     
    Also I noticed  you are used YourComboBox.Valuestr()
    use YourComboBox.selection() instead.
     
    Also I see you add range in the excuteQuery(), this will add range and will not set the combo box field try to set the field on the Write() method. Try my suggestions and tell us if it is help you.
     
     
    Thanks
    Waed Ayyad
  • Faqruddin Profile Picture
    Faqruddin 1,869 on at
    How to call more than two fields in SysListPanelRelationTableCallback
    Hello Waed,
     
    Hope you clear with my last reply. Please let me know If you need me to provide more information.
     
    Thanks
  • Faqruddin Profile Picture
    Faqruddin 1,869 on at
    How to call more than two fields in SysListPanelRelationTableCallback
    Hello Waed,
     
    Its Custom form. The combo box is not bound to the datasource. Because the actual datasource(DAWCustomerSeqMaster) has multiple repeated days as a normal string field. So I added combo box WeekDays enum to filter the related data from datasource. Now my target is I need to insert the selected combo box Week Day value in the custom table called DAWCustomerSeqMaster. Please see below screenshot I'm moving Select Customer To Assign from left to right Assign new customers to make the customer available on specific day for specific Rout in DAWCustomerSeqMaster table. The records CustAccount and RoutID is successfully created in DAWCustomerSeqMaster. But In DAWCustomerSeqMaster I have one more field called Day and I need to fill this field from WeekDays combo box selection once I move the customer from left to right.
     



    Please have look my form full code.

    [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();
            }
        }
    }

     
    Thanks
  • Waed Ayyad Profile Picture
    Waed Ayyad 6,195 Super User 2024 Season 2 on at
    How to call more than two fields in SysListPanelRelationTableCallback
    Hello Faqru,
     
    I need to ask you some questions in order to help you better:
     
    Does the form is custom form or standard?

    Does the Combo box is bound to the datasource?
    if not why you don’t bound it to the datasource?

    Did you try to add the field as a control on the form? 

    Thanks
    Waed Ayyad
     

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,113 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans