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

Lookup method for Form/Table

(0) ShareShare
ReportReport
Posted on by 177

Hi There, i got an requirement to develop an lookup method to populate data as per our business requirement. We are trying to customize LedgerParameters Form by adding a new field Local Ledger accounts and that field should populate lookup data based on below condition.  How can i write the below SQL code as lookup method inside LedgerParameters Form extension class.

SQL : SELECT MAINACCOUNTID,NAME  FROM CNLLUXLOCALACCOUNTMAPPINGVIEW INNER JOIN COMPANYINFOENTITY
ON CNLLUXLOCALACCOUNTMAPPINGVIEW.DATAAREA = COMPANYINFOENTITY.DATAAREA
INNER JOIN MAINACCOUNTLEGALENTITY ON
COMPANYINFOENTITY.RECID = MAINACCOUNTLEGALENTITY.LEGALENTITY

Thanks & Regards,

Prem

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

    Hi Prem,

    What is the CNLLUXLOCALACCOUNTMAPPINGVIEW? This is a customization. Can you explain the lookup requirement with words instead of SQL statements including views which we don't know any detail about?

    A standard lookup for main accounts from the current legal entity is a standard component. You can look at examples; e.g. Inventory posting profiles.

  • Alex VN Profile Picture
    1,994 on at

    Hi Prem,

    I agree with Andrea that we might need to have more information but based on your requirement, you should add the extension field first and then use onlookup event handler and build X++ queries to "override" the look up method.

    This might help you when you build the query:

    support.microsoft.com/.../an-x-query-example-for-microsoft-axapta-that-you-can-use-when-you-want-to-use-multiple-criteria-d0cd8715-0a01-7716-a10c-7927185944be

    Hope it helps.

  • huijij Profile Picture
    19,811 on at

    Hi Prem,

    You can try to add logic in the lookup event handler method of the form string control,sysTableLookup.addLookupField() to add lookup field,

    QueryBuildDataSource.addLink() to add relationships:

    msdynamics.nevoitech.com/.../

    community.dynamics.com/.../add-link-to-existing-query

  • PK69 Profile Picture
    177 on at

    Hi Judy, I did exactly what you had mentioned. I had created Form extension class and added my lookup field's onlookup event handler and there i had written logic to populate mainaccountid and name from mainaccount table. But, as per my requirement, i need to populate those details which satisfies condition like CNLLUXLocalAccountMapping.Dataarea = MainAccountLegalEntity.Legalentity

    Here CNLLUXLocalAccountmapping is our customized view which returns MainAccountId,Name from Mainaccount table as per some conditions. But that view returns values for all legal entities but we want to populate only those records for which equals with MainAccountlegalEntity.LegalEntity.  

  • PK69 Profile Picture
    177 on at

    On top of that we cant simply join CNLLUXLocalAccountMapping.Dataarea with MainAccountLegalEntity.Legalentity directly

    We need to join MainAccountLegalEntity.Legalentity  with CompanyInfo.recid and from there

    CompanyInfo.dataraea with CNLLUXLocalAccountMapping.Dataarea    to populate mainaccount details for that specific Company

  • huijij Profile Picture
    19,811 on at

    Hi Prem,

    With fetchMode(QueryFetchMode::One2One) you can innerJoin 3 tables together:

    dynamicsuser.net/.../help-wanted-to-innerjoin-3-tables-together-using-x-query

    Hope it will help you.

  • PK69 Profile Picture
    177 on at

    Hi Andre. you said we can take Inventory posting profiles have the standard lookup for mainaccounts. Can you please be more elaborate on that like which forms or methods helps me to populate mainaccount.mainaccountid,mainaccount.name as a lookup  for that particular legal entity. Thanks in advance

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

    Hi Prem,

    One of the many examples would be the form which opens when you navigate to: Inventory management > Setup > Posting > Posting.

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
Abhilash Warrier Profile Picture

Abhilash Warrier 669 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 384 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans
Liquid error: parsing "/globalsearch/?q=Bing++qupdate" - Nested quantifier +.