Filtering Subforms

erugalathaerugalatha Member Posts: 120
Hi,

I've added a subform for comments to the Service Order main form. This form already contained a subform for Service Item Lines.

I now want to filter my comments subform based on what line is selected in the Service Item Lines subform?

i.e. I'm filtering my second subform on the item selected in the first subform.
I want to only show comments that are entered for each service line item.

Is it possible to do this?

Thanks for any help.

Answers

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    You can't use a subform inside a subform ... at least not without some tricks.

    Here are some examples:
    Multiple Subform Sample v2.0
    New Multiple Subform Sample
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • erugalathaerugalatha Member Posts: 120
    Hi Luc,

    Sorry for confusion - the service item subform and the comment subform are both on the main service order form - they are not one inside the other.

    When I select a service item in the service item subform I want to filter the comment subform to only show comments that apply to the currently selected service item.

    It's difficult to explain.
  • 2tje2tje Member Posts: 80
    create the subform with item lines first.
    in this form create a subform with the comment lines
    then create the mainform and put the first subform in it.

    It is not recommended by Navision, but it should work
  • erugalathaerugalatha Member Posts: 120
    ok thanks for replies. romans multiple subform is what I'm trying to do.
    In his subform for SalesLines he has defined a function called IsSelectedLineChanged and in the code of the OnTimer in his main form he has the following:

    // Check if the user has scrolled headers or subform lines.
    IF NOT CurrForm.SalesLines.FORM.IsSelectedLineChanged THEN
    // Don't do anything if the subform line is still the same as //<TimerInterval>ms ago.
    EXIT;

    I've done the same in my forms and code but I get the error when I compile:

    "You have defined an unknown variable.

    IsSelectedLineChanged

    Define the variable under 'Global C/AL Symbols'."

    It's like the function IsSelectedLineChanged is not visible (in scope) from the mainform.

    Anyone some ideas what I'm missing?
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    erugalatha wrote:
    It's like the function IsSelectedLineChanged is not visible (in scope) from the mainform.
    It's a function on your subform.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • erugalathaerugalatha Member Posts: 120
    yup ... that's where I have it defined.

    Compiler seems to think it's a variable.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    IF NOT CurrForm.SalesLines.FORM.IsSelectedLineChanged THEN
    

    Did you assign a name to your subform? Did you use this name in the above statement?
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • erugalathaerugalatha Member Posts: 120
    Yes, I called my subform 'ServItemLineSubForm' and my code is as follows:

    // Check if the user has scrolled headers or subform lines.
    IF NOT CurrForm.ServItemLineSubForm.FORM.IsSelectedLineChanged THEN
    // Don't do anything if the subform line is still the same as <TimerInterval>ms ago.
    EXIT;
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Check if your function has the Local-property set to <No>?
    See with <F5> if you can locate your function by navigating through CurrForm -> Controls -> <nameofyoursubform> -> Functions -> FORM
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • erugalathaerugalatha Member Posts: 120
    That was it Luc ... local set to No :/

    Thank you.
Sign In or Register to comment.