Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Add existing records from different table view through sub-grid

(0) ShareShare
ReportReport
Posted on by 873

Hello,

I have a table called Employee Payroll Control that has a relationship with the Payroll control table as Many to One.

What I am trying to achieve is the below:

When the user clicks the "Add Existing records" from the Employee Payroll Control sub-grid and opens the advanced lookup popup to find the records he wants, I would like to add a view that allows the employee to select different Payroll controls based on the filter that he needs to apply.

2055.Image-1.png

I tried to apply the below condition on the Payroll Control View that I created:
View-Filter-2.pngImage-2.1.png

Knowing that the record exists in the Payroll control with the same condition:
Record-Exist-in-payroll-control.png

But it seems due to the relationship type it will never fetch this data as it will always look only for the employees that have payroll control. In my requirement regardless if the employee has or doesn't have payroll control I want the user to be able to select multiple payroll controls and associate them with the employee from the Payroll control view that I want to create.

To make it work as needed, do I have to add another relationship type as N:N instead of N:1, or is that okay if keep the N:1 with N:N?

I saw this amazing blog post by Bipin Kumar  but he's modifying the LookUp View directly which is different a little from my requirement:
Dynamics 365 – Sub grid Add Existing Look up View N:N – xrm CRM Dynamics (wordpress.com)

What might be the solution to achieve the above requirement? Could you please provide a similar example?

Any help is highly appreciated.

Best regards,
EBMRay

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add existing records from different table view through sub-grid

    Hi EBMRay,

    I see. However, The easiest way to do that is that fill in the Payroll Control lookup field on the Employee Payroll Control form. 

    If you want to try this blog(Dynamics 365 – Sub grid Add Existing Look up View N:N – xrm CRM Dynamics (wordpress.com)), keep the N:1 relationship is ok. However, I'm not sure this can work for you.

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: Add existing records from different table view through sub-grid

    Hi  ,

    Thank you for your reply.

    Yes, I meant like this, but the main goal is to create a view in the "Employee Payroll Control" that fetches data from the "Payroll Control" table filtered based on the country that is assigned from the payroll control.

    Example: If you created a payroll control in the payroll control table and you assigned the country "Lebanon" the expected result in the employee payroll control is to display the list of those payroll controls.

    Screenshot-2022_2D00_06_2D00_16-085422.png

    Alternatively, I am trying to create a view in the Employee payroll control that gets data from a completely different table.

    Please let me know if you need any more information.

    Best regards,

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add existing records from different table view through sub-grid

    Hi EBMRay,

    "Because I believe now if you remove this payroll control that you provided in the screenshot from the employee payroll control this record will not be visible and even I cannot add the same payroll control to a different employee."

    Do you mean that I do like this:

    pastedimage1655345583628v1.png

    If so, yes, it would disappear. However, it would also disappear in the view grid because Payroll control table doesn't contain data:

    pastedimage1655345940458v2.png

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: Add existing records from different table view through sub-grid

    Hi   ,

    It seems that the "Payroll control" that has country Lebanon should at least be assigned with one employee payroll control in order to be displayed in "Payroll Control - Lebanon" view.
    My requirement is regardless if it is assigned to an employee or not the list of the payroll controls should be displayed based on the filter that we applied in the view in the advanced lookup from the Payroll Control table.

    Because I believe now if you remove this payroll control that you provided in the screenshot from the employee payroll control this record will not be visible and even I cannot add the same payroll control to a different employee.
    Error-message-when-I-try-to-add-to-a-different-employee.png

    What will be the solution in that case?

    If the above is hard to be achieved I thought about a workaround like having a custom button on the grid that opens this view, allowing the user to choose the payroll controls and upon submission, the logic behind should relate those records with the current employee. What do you think before going with that option can be achieved without this?

    Awaiting your response.

    Best regards,
    EBMRay

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add existing records from different table view through sub-grid

    Hi EBMRay,

    I tried to reproduce your error but not successfully. When I click 'Adding Existing Employee Payroll Control' button and select that view, the Employee Payroll Control record would appear. Please see the following details:

    1. I created 3 tables: Employee(has 1:N relationship with Employee Payroll Controls), Employee Payroll Controls and Payroll control(has 1:N relationship with Employee Payroll Controls).

    2. In the Employee Payroll Controls, I created a view. Its filter is like this:

    pastedimage1655271305396v1.png

    3. When  I click 'Adding Existing Employee Payroll Control' button and select that view, the record will show:

    pastedimage1655271522114v2.png

    Did I do something wrong?

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: Add existing records from different table view through sub-grid

    Hello  ,

    I would highly appreciate your feedback regarding the above.

    Please let me know if you require any more information.

    Best regards,
    EBMRay

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: Add existing records from different table view through sub-grid

    Hi  ,

    Please find below the relationship type between the Employee and the Payroll Control:
    One_2D00_To_2D00_Many.png

    I am not using the above relationship type since I created an intermediate table called Employee Payroll Control that has many-to-one between both tables:

    Employee-Payroll-Control-1.pngPayroll-Control-with-employee-payroll-control-relation1.png

    Shall I add N: N between the employee table and payroll control in the Employee payroll control table to achieve this kind of requirement?

    Please let me know if you need any further information.

    Best regards,
    EBMRay

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add existing records from different table view through sub-grid

    Hi EBMRay,

    What's the relationship between Employee entity and  Payroll control entity?

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