Skip to main content

Notifications

Announcements

No record found.

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

Lookup method is not visible even after writing lookup method on Form>DS>Field

(0) ShareShare
ReportReport
Posted on by 13
Hi all,
 
I have written lookup method on form > ds > field. Even after my lookup is not visible. Please help with your solution.
 
[ExtensionOf(formDataFieldStr(CustTable, CustTable, PriorityName2))]final class CustTable_FormDS_Field_PriorityName2_Extension{    public void lookup(FormControl _formControl, str _filterStr)    {        //Specify the name of the table the lookup should show data from.        SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tableNum(CustDeliveryPriority), _formControl);        //Create a new query        Query                   query = new Query();        QueryBuildDataSource    queryBuildDataSource;        QueryBuildRange         queryBuildRange;        next lookup(_formControl, _filterStr);         //Specify the name of the table the lookup should show data from.        queryBuildDataSource = query.addDataSource(tableNum(CustDeliveryPriority));        queryBuildRange = queryBuildDataSource.addRange(fieldNum(CustDeliveryPriority,PriorityName));        queryBuildRange.value(strFmt('(PriorityName != /%1/)', queryValue(/Ten days/)));        sysTableLookup.addLookupfield(fieldNum(CustDeliveryPriority, PriorityId));        sysTableLookup.addLookupfield(fieldNum(CustDeliveryPriority, PriorityName));        sysTableLookup.addLookupfield(fieldNum(CustDeliveryPriority, Description));         sysTableLookup.parmQuery(query);        sysTableLookup.performFormLookup();    }}
 
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    Lookup method is not visible even after writing lookup method on Form>DS>Field
    To show your custom lookup at form level, the procedure is to write lookup code either at form ds field level or form control. If you are using COC, you need to write your lookup code and should override the standard lookup from init method of form datasource using register override method. If you are using event, then you should make use of onlookup event handler where you will cancel super call of standard lookup which makes sure our custom lookup will execute.
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,379 Most Valuable Professional on at
    Lookup method is not visible even after writing lookup method on Form>DS>Field
    This isn't a correct approach. Either use an event handler with cancelSuperCall(), or you'll need to utilize registerOverrideMethod(). You can find an example in How To Override An Existing Lookup Method: Chain Of Command, for instance.
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,264 Super User 2024 Season 2 on at
    Lookup method is not visible even after writing lookup method on Form>DS>Field
    Hi Community User,

    You can try to do the lookup on form control, by creating an extension of the form and use Register override method
     
    [ExtensionOf(formStr(CustTable))]
    final class CustTableForm_Extension
    {
        public void init()
        {
            next init();
    
            YourFormControlName.registerOverrideMethod(methodStr(FormDataObject, lookup), formMethodStr(CustTable, overridePriorityName2Lookup));
        }
    
        public void overridePriorityName2Lookup(FormStringControl _formControl)
        {
      //add your lookup code here
    ​​​​​​​ //Specify the name of the table the lookup should show data from. SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(CustDeliveryPriority), _formControl); //Create a new query Query query = new Query(); QueryBuildDataSource queryBuildDataSource; QueryBuildRange queryBuildRange; //Specify the name of the table the lookup should show data from. queryBuildDataSource = query.addDataSource(tableNum(CustDeliveryPriority)); queryBuildRange = queryBuildDataSource.addRange(fieldNum(CustDeliveryPriority,PriorityName)); queryBuildRange.value(strFmt('(PriorityName != /%1/)', queryValue(/Ten days/))); sysTableLookup.addLookupfield(fieldNum(CustDeliveryPriority, PriorityId)); sysTableLookup.addLookupfield(fieldNum(CustDeliveryPriority, PriorityName)); sysTableLookup.addLookupfield(fieldNum(CustDeliveryPriority, Description)); sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup(); } }

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,661 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,379 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans