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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Custom lookup on reference group field

(1) ShareShare
ReportReport
Posted on by 513
Hi..

I have this out of the box lookup that has Purchase agreement field not filterable!



I tried to develop a custom lookup using different ways:
 
1- use a table method 




But The Purchase agreement field is empty.. it only shows values if I made the getPurchNumberSequence a display method.. but again I'm not able to apply filter!

2- add a custom query... it doesn't work and the column PurchNumberSequence doesn't appear at all

3- create a view that has the desired fields but it gives the error: AgreementLine isn't a form primary datasource

Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at
    Your attempt to use fields from different tables in addLookupField() is wrong. addLookupField() adds fields from the table that the SysReferenceTableLookup object was created for.
     
    For example, look at this code:
    lookup = SysReferenceTableLookup::newParameters(tableNum(AgreementLine), ...
    lookup.addLookupField(fieldNum(PurchAgreementHeader, PurchNumberSequence));
    You believe it adds PurchAgreementHeader.PurchNumberSequence, but in fact, it adds a field from AgreementLine that happen to have the same ID that PurchNumberSequence has in PurchAgreementHeader table. That's clearly wrong.
     
    Also, shouldn't you override FormReferenceControl.lookupReference() instead of lookup()?
  • AbdullahAhmed_ Profile Picture
    513 on at
    Hello martin,

    Yes, I should override LookupReference... and you're right that 
    lookup.addLookupField(fieldNum(PurchAgreementHeader, PurchNumberSequence));
    would pick another field from AgreementLine but it was a desperate shot!

    any ideas to make that work?
  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at
    If you want to return fields from different tables and avoid display method, then using a view is a viable option.
  • AbdullahAhmed_ Profile Picture
    513 on at
    Here's the view I created:
    I added PurchCommitmentLine_PSN because it's a main datasource in the form!



    I get this error: "Could not process the lookupRecord value on the Args instance. The table 'AgreementLine' does not exist as a root FormDataSource for the form 'PurchCommitment_PSN__AgreementLine_SysTCL'."
  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at
    Please show us your code.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 658

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 468 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 333 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans