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 :
Microsoft Dynamics AX (Archived)

Validate relations between 2 fields in a form

(1) ShareShare
ReportReport
Posted on by 576

Hello Everyone

how can i create a form contain tow fields ,the tow field have a relation like next photos

1-seg 1 has sub segnamed sub seg 1

seg1.png

2-after select sub seg2 i will change the parent (Segment to seg2)

Seg2.png

3-after it the Sub-seg become clear 

seg3.png

Although if i change it manually the Sub-seg will become empty

seg4.png

---------------------------------------------------------

when i created 2 tables like these and create the relation between the 2 tables

and added them to a form then created a lookup method like next photo

seg6.png

but all the department displayed without select the locations

so i need to display the departments depend on the location(The first choice)

Thank you

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,158 Super User 2025 Season 2 on at

    Hi Ismail,

    I don't know if you did the exact same thing as on your example you provided. It seems like you are using the setup tables Location and Department as datasources on the form. The example you provided has one table with the fields Segment and Sub segment. These fields to have the lookup to the setup tables. So you have tried something different here.

    What is your exact requirement? If you provide more background information, we can help you in a better way.

  • Ismail Mohamed Profile Picture
    576 on at

    thanks André Arnaud de Calavon

    i just need the lookup in departmentId consider the relation between location and department tables

    Each location has more then one department

    so when i press on departmentId the displayed data belong to selected location

  • André Arnaud de Calavon Profile Picture
    301,158 Super User 2025 Season 2 on at

    Hi Ismail,

    Did you already searched for differences between the segment/subsegment example and what you have developed? I notice lookup methods on the form controls. Are you overriding the standard? What is the content of those lookup methods?

  • Ismail Mohamed Profile Picture
    576 on at

    André

    don't think about segment and sub maybe it's wrong example

    the code in the lookup is

    public void lookup()

    {

        Query query;

       Form _formControl;

       SysTableLookup sysTableLookup;

       QueryBuildRange queryBuildRange;

       QueryBuildDataSource queryBuildDataSource;

       //Table7 table7;

        // Instantiate sysTableLookup object using table which will provide the visible

       sysTableLookup = SysTableLookup::newParameters(tableNum(a_Locations),this);

       query = new Query();

       queryBuildDataSource = query.addDataSource(tableNum(a_Locations));

       sysTableLookup.addLookupfield(fieldNum(a_Locations,Locations));

       sysTableLookup.parmQuery(query);

       sysTableLookup.performFormLookup();

    }

    and in a_Departments

    public void lookup()

    {

        Query query;

       Form _formControl;

       SysTableLookup sysTableLookup;

       QueryBuildRange queryBuildRange;

       QueryBuildDataSource queryBuildDataSource;

       //Table7 table7;

        // Instantiate sysTableLookup object using table which will provide the visible

       sysTableLookup = SysTableLookup::newParameters(tableNum(a_Departments),this);

       query = new Query();

       queryBuildDataSource = query.addDataSource(tableNum(a_Departments));

       sysTableLookup.addLookupfield(fieldNum(a_Departments,a_DepartmentId));

       sysTableLookup.addLookupfield(fieldNum(a_Departments,Name));

       sysTableLookup.parmQuery(query);

       sysTableLookup.performFormLookup();

    }

    so when i open department edit just display the departments related to it's location that selected in locations edit

    sorry if i can't explain the issue correctly 

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans