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

Community site session details

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

to filter the field on form using field on another form

(1) ShareShare
ReportReport
Posted on by 1,836
field not getting the data showing invalid range in form 
 
 
I have the same question (0)
  • Dineshkarlekar Profile Picture
    1,836 on at
    to filter the field on form using field on another form
    here is my code i was trying to get values from this ,
     
     [FormControlEventHandler(formControlStr(DT_ShiplicensePlateForm_dk, DT_Licenseship_dk_LicensePlateId), FormControlEventType::Lookup)]
        public static void DT_Licenseship_dk_LicensePlateId_OnLookup(FormControl sender, FormControlEventArgs e)
        {
            FormRun                 element;
            FormControl             formCtrl;
            Query                   query;
            SysTableLookup          sysTableLookup;
            QueryBuildDataSource    queryBuildDataSource;
    
            element  = sender.formRun();
            formCtrl = element.design().controlName(formControlStr(InventTransferOrders, LineViewHeader_InventLocationIdFrom));
    
            query = new Query();
            sysTableLookup = SysTableLookup::newParameters(tableNum(DT_Licenseship_dk), sender);
            queryBuildDataSource qbdsLicenseship_Tbl = query.addDataSource(tableNum(DT_Licenseship_dk));
            QueryBuildDataSource qbdsInventTransferTable = qbdsLicenseship_Tbl.addDataSource(tableNum(InventTransferTable));
            qbdsInventTransferTable.relations(true);
    
            sysTableLookup.addLookupfield(fieldNum(DT_Licenseship_dk,LicensePlateId ));
    
            qbdsLicenseship_Tbl.addRange(fieldNum(InventTransferTable,InventLocationIdFrom)).value(formCtrl.valueStr());
           
    
            sysTableLookup.parmQuery(query);
            sysTableLookup.performFormLookup();
    
        }
     
  • Verified answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at
    to filter the field on form using field on another form
    Hi Dinesh, Are you getting any value in formControl, if nit then try changing formControl to FormStringControl.
  • Verified answer
    Martin Dráb Profile Picture
    237,668 Most Valuable Professional on at
    to filter the field on form using field on another form
    I would use queryValue() (to escape possible special characters) and look at what range value you have in your query. You can see it in debugger, or put it to infolog as in the example below:
    [FormControlEventHandler(formControlStr(DT_ShiplicensePlateForm_dk, DT_Licenseship_dk_LicensePlateId), FormControlEventType::Lookup)]
    public static void dt_Licenseship_dk_LicensePlateId_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        FormRun element  = sender.formRun();
        FormStringControl locationIdCtrl = element.design().controlName(formControlStr(InventTransferOrders, LineViewHeader_InventLocationIdFrom));
    
        Query query = new Query();
    	
        QueryBuildDataSource qbdsLicenseship_Tbl = query.addDataSource(tableNum(DT_Licenseship_dk));
        QueryBuildDataSource qbdsInventTransferTable = qbdsLicenseship_Tbl.addDataSource(tableNum(InventTransferTable));
        qbdsInventTransferTable.relations(true);
    
        qbdsLicenseship_Tbl.addRange(fieldNum(InventTransferTable, InventLocationIdFrom)).value(queryValue(locationIdCtrl.text()));
    	
        // Just for debugging
        info(qbdsLicenseship_Tbl.toString());
    
        SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(DT_Licenseship_dk), sender);
        sysTableLookup.addLookupfield(fieldNum(DT_Licenseship_dk, LicensePlateId));
    
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }
  • Dineshkarlekar Profile Picture
    1,836 on at
    to filter the field on form using field on another form
    hi guys thanks for reply 
    i have to write code on form overide method 
    it is working fine now, i have to use different tables . 
       public void lookup(FormControl _formControl, str _filterStr)
                {
                    //super(_formControl, _filterStr);
                    Query                   query = new Query();
                    QueryBuildDataSource    qbdsInventDim_Tbl,qbdsInventSum;
                    SysTableLookup          sysTableLookup;
                    Inventtransfertable     inventtransfertable;
                    inventtransfertable  = element.args().record();  
         
                    sysTableLookup = SysTableLookup::newParameters(tableNum(inventDim),_formControl);
    
                    qbdsInventDim_Tbl   = query.addDataSource(tableNum(InventDim));
                    qbdsInventSum = qbdsInventDim_Tbl.addDataSource(tableNum(InventSum));
                    qbdsInventSum.relations(false);
                    qbdsInventSum.addLink(fieldNum(InventDim,inventDimId),fieldNum(InventSum,inventDimId));
                    qbdsInventSum.joinMode(JoinMode::ExistsJoin);
                    qbdsInventSum.addRange(fieldNum(InventSum,AvailPhysical)).value(SysQuery::valueNot(0));
                    qbdsInventDim_Tbl.addGroupByAndSelectionField(fieldNum(InventDim,LicensePlateId));
                    qbdsInventDim_Tbl.addRange(fieldNum(inventdim , InventLocationId)).value(Inventtransfertable.InventLocationIdFrom);
            
                    qbdsInventDim_Tbl.orderMode(OrderMode::GroupBy);
                    sysTableLookup.parmUseLookupValue(false);
                    sysTableLookup.addLookupField(fieldNum(inventDim, LicensePlateId ));
           
                    sysTableLookup.parmQuery(query);
                    sysTableLookup.performFormLookup();
                }
    thanks 
    regards ,
    Dinesh

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 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans