Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

to filter the field on form using field on another form

(1) ShareShare
ReportReport
Posted on by 1,479
field not getting the data showing invalid range in form 
 
 
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 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
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,842 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();
    }
  • Verified answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 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.
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 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();
    
        }
     

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,969 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,842 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans