web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

How to filter a datasource of a lookup form depending on the value on the calling form?

(0) ShareShare
ReportReport
Posted on by 46

I have been looking around the internet looking ways to filter a datasource FROM a lookup form, but ended getting results like "filtering another datasource USING a lookup form".

Instead, I am looking a solution to filter a lookup form considering the value of the calling form:

Specs below:

(1) My form has a datasource on a grid with two columns: Name and Media.

(2) Media is a referenced column.

(3) Media is a customized EDT set its property FormHelp to MediaLookupForm.

pastedimage1588287548687v2.png

pastedimage1588286000310v4.png

(4) MediaLookupForm is a standard lookup form (not a runtime lookup form) and has its own datasource.

pastedimage1588285841797v2.png

(5) MediaLookupForm's datasource contains records both for a LOCAL item (ie LOC-0000789) & an EXPORT item (ie EXP-0000645).

          If Name is a LOCAL item, records in the MediaLookupForm should only for LOCAL items.

                 pastedimage1588286239438v7.png

          If Name is an EXPORT item, records in the MediaLookupForm should only for EXPORT items.

                pastedimage1588286549089v11.png

(6) The parent table for Name has the field LOCAL/EXPORT enum.

(7) The parent table for Media has also the field LOCAL/EXPORT enum.

Question: How can I filter the datasource on MediaLookupForm considering the value on Name?

Links are highly appreciated!

Thank you so much!

I have the same question (0)
  • MATTGUO Profile Picture
    22,349 Moderator on at

    Hi Kashiru,

    Please provide some screenshots so that we can better understand your requirement.

    Are you going to create a lookup form with filter?

    The best practice is to have filter code written in data source executequery method.

    Have a look at the blog:

    stoneridgesoftware.com/.../

  • Kashiru Kito Profile Picture
    46 on at

    Hi @MATTGOU, thanks for stopping by.

    Thanks for the link but I came to this previously but this is not my requirement.

    I revised my post with screenshots and more specific details.

    Thank you for your assistance. Stay safe and well.

  • Mea_ Profile Picture
    60,284 on at

    Im not sure why you say that its not your case. In the lookup form you can get access to a caller record, having it you can get enum value and put a range on a query by that enum.

  • Kashiru Kito Profile Picture
    46 on at

    Hello all, I was able to find a solution using this link: https://www.schweda.net/blog_ax.php?bid=351&wdl=en

    Using FormRun calss,  I was able to iterate across the datasources of the calling form and find my the value which I want to filter my lookup form (coded to my lookup form's init function) before showing it on the calling form.

    ################################## Q U O T E   S T A R T ##################################

        // Get value from calling datasource (form with multiple datasources)
        if(element.args() && element.args().caller() && element.args().caller().handle() == className2Id('formRun'))
        {
            formRun = element.args().caller();
            for (i = 0; i <= formRun.dataSourceCount(); i++)
            {
                formDataSource = formRun.datasource(i);
                if (formDataSource && formDataSource.table() == tablenum(inventDim))    // Search for specific table
                {
                    inventDim = formDataSource.cursor();
                    break;
                }
            }
            if(inventDim)
            {
                info(inventDim.InventLocationId);
            }
        }

    #################################### Q U O T E   E N D ####################################

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 700 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 567 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 408 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans