Skip to main content

Notifications

Announcements

No record found.

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

to filter the records in grid based on the field value in header

(3) ShareShare
ReportReport
Posted on by 1,457
hi 
everyone,
I was trying to filter the records in line based on the field value in header , but i am not getting the desired  output , please anyone help me on this .
my code is below . 
 
 
i have debugged the code not getting the record , please suggest hoe can i get the header record .
 
thanks ,
Regards,
Dinesh
  • Layan Jwei Profile Picture
    Layan Jwei 7,264 Super User 2024 Season 2 on at
    to filter the records in grid based on the field value in header
    Hi Dinesh,
     
    You mentioned in another thread that my answers helped. So please don't forget to verify the answers that helped. And if you are facing an issue with verifying, then please mention the answers and moderators will verify it for you.
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    to filter the records in grid based on the field value in header
    Can you show us your form design? Because you are saying you need to filter lines record based on header warehouse ID. In that case you can simply put a relation between header and line. But why do you require some custom code to do this? Can you give us your full business requirement?
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,264 Super User 2024 Season 2 on at
    to filter the records in grid based on the field value in header
    Hi Dinesh,

    Did you check the link i sent you in previous replies. it should solve your issue. https://daxingwitheshant.blogspot.com/2019/04/how-to-filter-grid-based-on-control.html
     
    just put your code on the form datasource of the line table

    [ExtensionOf(formDataSourceStr(YourForm,YourLinesTable))]
    final class YourClass_Extension
    {
        public void executeQuery()
        {
            next executeQuery();

            this.query().dataSourceTable(tableNum(YourLinesTable)).addRange(fieldNum(YourLinesTable, LocationId)).value(SysQuery::value(headerTable.LocationId));
        }
    }
     
    and as the blog showed, if the header can be modified then you need to add code there as well

    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
     
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    to filter the records in grid based on the field value in header
    yes you are right , how can i get this done then ,can you please guide me on this 
  • Layan Jwei Profile Picture
    Layan Jwei 7,264 Super User 2024 Season 2 on at
    to filter the records in grid based on the field value in header
    Hi Dinesh,

    So if LocationId is the warehouse in the header and it's value is already filled, why are you then overriding it with this line of code?
    locationId  = DTDMCHeaderLines::findRecId(element.args().record().RecId).inventLocationId;

    So to make sure i understood your requirement correctly.

    When you first open the form, you want the lines to be filtered based on the header field. where the header field is already filled...right?
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    to filter the records in grid based on the field value in header
    Location id is  warehouse in header , the data is get into the form unsing insert method i so i want to filter the lines tab using location ie warehouse which are common but i cant use join here , so i have removed joined form data source from lines so all the lines are getting displayed . yes dmc header is first datasource in form , but still i am getting null values i am unable to upply filter on form can you help me on this please .
  • Layan Jwei Profile Picture
    Layan Jwei 7,264 Super User 2024 Season 2 on at
    to filter the records in grid based on the field value in header
    Hi Dinesh,

    What is LocationId? is it a defined variable or an existing field on the form?

    ​​​​​​​Just to understand if you are trying to set the LocationId field when the form is first open from the lines?

    if it was an actual field, why do u need element.args().record() in the first place? why not fill LocationId directly? isn't DTDMCHeader the first datasource in the form?


    Also check this link in general
    https://daxingwitheshant.blogspot.com/2019/04/how-to-filter-grid-based-on-control.html
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    to filter the records in grid based on the field value in header
    when i open the from for specific header record it should show the record only with warehouse in header ,now i am getting all the warehouse in lines , an in debugger i am getting the null values .
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    to filter the records in grid based on the field value in header
    hi ,
    Thanks for reply ,
    Location id is empty .i am not getting value in 
    element.args().record()
  • Layan Jwei Profile Picture
    Layan Jwei 7,264 Super User 2024 Season 2 on at
    to filter the records in grid based on the field value in header
    Hi Dinesh,

    What header record you are not getting? which line of code are you referring to? as I don't understand.
    Do you mean LocationId is empty or what?

    Also can you please take a screenshot of the form, showing the header field and grid?

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,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans