Skip to main content

Notifications

Announcements

No record found.

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

How to filter a filed in 2nd tab based on selecting records in 1st tab in form

(0) ShareShare
ReportReport
Posted on by 148

7367.pastedimage1675952006874v1.png

Hello everyone,

consider above image.

form name : Bank facility agreements (standard form).

as in image, we have general tab and actions tab.( general tab is standard and actions tab is customized)

we have records in action tab, if we select any facility type in general tab those type records should show in actions tab. (facility type is common field in both tabs).

how to filter like above scenario. please advise.

Thanks in advance.

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: How to filter a filed in 2nd tab based on selecting records in 1st tab in form

    If it's just about two table, we already discussed the solution.

    Your previous comment sounded like that you want to take into account both Parent and Child, but now I see that there is nothing like in your requirement.

  • Prasanth Profile Picture
    Prasanth 148 on at
    RE: How to filter a filed in 2nd tab based on selecting records in 1st tab in form

    While user selects facility type in general tab those particular records we need to show in action tab.

    let us assume:

    1. In action tab 5 records are there, out of 5, 3 are LC ,1 is TR and 1 is LG.

    2. now user selects LC in general tab, in action tab only LC records should display. If user selects TR in general tab, in action tab only TR records should display.

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: How to filter a filed in 2nd tab based on selecting records in 1st tab in form

    Unfortunately your scenario isn't clear to me, therefore I'm unable to design a solution. I would need more information about how you want to filter the data.

  • Prasanth Profile Picture
    Prasanth 148 on at
    RE: How to filter a filed in 2nd tab based on selecting records in 1st tab in form

    Yes martin . Is any other way to achieve above scenario ?

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: How to filter a filed in 2nd tab based on selecting records in 1st tab in form

    That you have a relation between the child table and the custom table has no effect, because - as you said - the custom table is linked to the parent table and not the child table.

  • Prasanth Profile Picture
    Prasanth 148 on at
    RE: How to filter a filed in 2nd tab based on selecting records in 1st tab in form

    Thank you Martin and Girish.

    I followed Martin guidelines, It's working now but impacting other functionality. 

    pastedimage1676017087989v1.png

    1. Here I Used 3 tables. BankDocumentFacilityAgreements (Parent table), BankDocumentFacilityAgreementLine (Child table), ApntLetterOfCreditImportAction (custom table)

    2. we have one relation between parent table and custom table (Agreement number ) ( in custom datasource I used delayed and join source as parent table so based on that only particular agreements it's showing.)

    3 we have one more relation between child table and custom table (facility type) (if I use in custom data source properties, delayed and child table  facility type filter will work but agreement number filter will not work )

    How to achieve above scenario.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: How to filter a filed in 2nd tab based on selecting records in 1st tab in form

    What is the relation between BankDocumentFacilityAgreementLine and  BankDocumentFacilityType?

    Have you debugged the code and find out whether BankDocumentFacilityType returns any buffer?

    Seems the find method you have added is wrong I guees - Can you double check that one.

    Also call research method after adding range to ApntLetterOfCreditImportAction datasource.

    Thanks,

    Girish S.

  • Prasanth Profile Picture
    Prasanth 148 on at
    RE: How to filter a filed in 2nd tab based on selecting records in 1st tab in form

    [FormDataSourceEventHandler(formDataSourceStr(BankDocumentFacilityAgreement, BankDocumentFacilityAgreementLine), FormDataSourceEventType::SelectionChanged)]
        public static void BankDocumentFacilityAgreementLine_OnSelectionChanged(FormDataSource sender, FormDataSourceEventArgs e)
        {
            FormDataSource                      BankDocumentFacilityAgreementLine_ds;
            BankDocumentFacilityAgreementLine   BankDocumentFacilityAgreementLine;
            FormDataSource                      ApntLetterOfCreditImportAction_ds;
            ApntLetterOfCreditImportAction      ApntLetterOfCreditImportAction;
            BankDocumentFacilityType            BankDocumentFacilityType;
    
    
            BankDocumentFacilityAgreementLine_ds    = sender.formRun().dataSource(formDataSourceStr(BankDocumentFacilityAgreement,BankDocumentFacilityAgreementLine ));
            BankDocumentFacilityAgreementLine       = BankDocumentFacilityAgreementLine_ds.cursor();
    
            ApntLetterOfCreditImportAction_ds       = sender.formRun().dataSource(formDataSourceStr(BankDocumentFacilityAgreement, ApntLetterOfCreditImportAction ));
    
            BankDocumentFacilityType = BankDocumentFacilityType::find(BankDocumentFacilityAgreementLine.RecId);
    
            ApntLetterOfCreditImportAction_ds.query().dataSourceTable(tableNum(ApntLetterOfCreditImportAction)).addRange(fieldNum(ApntLetterOfCreditImportAction, FacilityTypeName)).value(BankDocumentFacilityType.FacilityTypeName);
    
        }

    Hi Martin and Girish.

    there is no direct relation between both tables. both are different datasources.

    I tried selectionChanged event it's working only for 1st record if we select 2nd record stil it's filtering 1st record values only. consider below snap.

    I pasted my code please advise .

    pastedimage1676004427392v1.png

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: How to filter a filed in 2nd tab based on selecting records in 1st tab in form

    Hi Prasanth,

    I agree with martin, it will work if there is a relation between the tables. Another option is to write the code on the modified method of the FacilityType control - In that method add the range to Action tab datasource for field FacilityType. Value should be Facility type on the general tab datasource.

    Also if you select any one of the record on the general tab - Action tab should automatically filter against the particular facility type - In that case you need to write code on SelectionChanged method to add range to it.

    Thanks,

    Girish S.

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: How to filter a filed in 2nd tab based on selecting records in 1st tab in form

    It'll work automatically if the data sources are linked through a Delayed link and there is a relation between those tables (that they have a field with the same name isn't relevant).

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... 292,162 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans