Skip to main content
Dynamics 365 Community / Forums / Finance forum / How to clear the combo...
Finance forum
Answered

How to clear the combobox value if I move to next values in the grid

editSubscribe (0) ShareShare
ReportReport
Posted on by 1,837
Hello,
 
I have a grid in the left side of the form which display data of some IDs. I have also combobox in DetailsHeader(Group) and its display weekdays. Here I need to clear the combobox and edit the combobox as manually once the value of Ids controller changed in the grid. For next Id2, Id3 values in the grid I need to clear the combobox and edit the combobox as manually. Please advice how can I achieve this. I'm using simple list and details grid form.
 
Thanks
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 1,898 on at
    How to clear the combobox value if I move to next values in the grid
    Hi Faqru,
     
    Try to verify it again I added the same comment here.
     
    Try to move your code to the active Event handler of form data source not to the modified as you want to clear the value once  you move from record to another. Try it and tell me the result, also I think you should add your code to the init method of the form if you want it to be empty when you open the form.
     
    I noticed you declare formRun = sender.datasource().formRun(); twice remove the second one. Also are you sure weekday.clear is working? Try to set the value to the default value of the Enum. Does the enum has empty value?
     
    Thanks 
    Waed Ayyad
  • Faqruddin Profile Picture
    Faqruddin 1,837 on at
    How to clear the combobox value if I move to next values in the grid
    Hello Waed,
     
    Its look there is technical issue in community. Once I click check box Does this answer your question? the whole page is freezed and keep loading. Could you please verify it from your end. Below reply
     
    Try to move your code to the active Event handler of form data
    source not to the modified as you want to clear the value once  you move
    from record to another. Try it and tell me the result, also I think you
    should add your code to the init method of the form if you want it to
    be empty when you open the form.
     
    I noticed you declare formRun = sender.datasource().formRun(); twice remove the second one. Also are you sure weekday.clear is working? Try to set the value to the default value of the enum. Does the enum has empty value ?
  • Waed Ayyad Profile Picture
    Waed Ayyad 1,898 on at
    How to clear the combobox value if I move to next values in the grid
    Hi Faqru,
     
    If moving the code to active method is solved your first issue. Mark it as verified answers in order to help other on the community in the future.
     
    Regards,
    Waed Ayyad
  • Faqruddin Profile Picture
    Faqruddin 1,837 on at
    How to clear the combobox value if I move to next values in the grid
    its look there is an isse in communty to verify correct answer. The page is freeze for long time. However the below code its solved as suggested by martin.
     
    WeekDays.selection(YourEnum::None)
  • Martin Dráb Profile Picture
    Martin Dráb 222,562 Super User on at
    How to clear the combobox value if I move to next values in the grid
    Please create a new thread for the other problem and explain it in detail there. It doesn't belong under the title "How to clear the combobox value if I move to next values in the grid".
     
    If the problem with combobox is resolved (which seems to be the case), please verify the answer.
  • Faqruddin Profile Picture
    Faqruddin 1,837 on at
    How to clear the combobox value if I move to next values in the grid
    Thank you martin. It works. Now the combo box is empty once I select next RoutId in the grid. But I have small thing left. I have SysListPanelRelationTableCallback and records still exists of previous selection of RoutID and WeekDay. I want to be empty SysListPanelRelationTableCallback  records once I select next RoutId in the grid. Please advice.
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 222,562 Super User on at
    How to clear the combobox value if I move to next values in the grid
    The combobox is based on an enum, right? Then resettting it means setting the default value into it. For example: WeekDays.selection(YourEnum::None).
     
    By the way, the condition DAWRoutes_RouteID.valueStr() !=null doesn't make a good sense because string in X++ can't ever be null. Also, you should refer to the data source field rather than the control. Therefore you can use simply if (dawRoutes.RouteID).
  • Faqruddin Profile Picture
    Faqruddin 1,837 on at
    How to clear the combobox value if I move to next values in the grid
    Thanks Waed. I moved my code to active() of datasource. Now its completely cleared no values found in the combo box at all to select :). I need combo box value also once I move from record to another.
     
     
        [DataSource]
        class DAWRoutes
        {
            /// <summary>
            ///
            /// </summary>
            /// <returns></returns>
            public int active()
            {
                int ret;
        
                ret = super();
                if(DAWRoutes_RouteID.valueStr() !=null)
                {
                    WeekDays.clear();
                }
        
                return ret;
            }
        }
  • Verified answer
    Waed Ayyad Profile Picture
    Waed Ayyad 1,898 on at
    How to clear the combobox value if I move to next values in the grid
    Hi Faqru,
     
    Try to move your code to the active Event handler of form data source not to the modified as you want to clear the value once  you move from record to another. Try it and tell me the result, also I think you should add your code to the init method of the form if you want it to be empty when you open the form.
     
    I noticed you declare formRun = sender.datasource().formRun(); twice remove the second one. Also are you sure weekday.clear is working? Try to set the value to the default value of the enum. Does the enum has empty value ?


    Thanks 
    Waed
     
     
     
     
     
  • Faqruddin Profile Picture
    Faqruddin 1,837 on at
    How to clear the combobox value if I move to next values in the grid
    Hello Waed,
     
    First thing the date is not placed on the grid. The date day enum is on DetailsHeader(Group) and its display weekdays  The grid contain list of data of RouteIDs. So whenever each time I select new RouteID from the gird left I need clear date enum. I follow below approach not worked. Please check my code. As you see below down when I shift to Rout-B and I need weeekdaysCombo to be empty. Currently the combo takes previous selection of Rout-A. The weekdays combo help to filters Customer available & not available data after weekday selection.
     
     
      [FormDataFieldEventHandler(formDataFieldStr(DAWCustSeq, DAWRoutes, RouteID), FormDataFieldEventType::Modified)]
        public static void RouteID_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
        {
            FormRun formRun = sender.datasource().formRun();
            DAWRoutes DAWRoutes = formRun.dataSource(formdatasourcestr(DAWCustSeq, DAWRoutes)).cursor();
            formRun = sender.datasource().formRun();
            FormComboBoxControl WeekDays = formRun.design(0).controlName("WeekDays");
            if(DAWRoutes.RouteID !=null)
                   {
                   
                   WeekDays.clear();
                   }
        }

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,030 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,562 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans