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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Sub-grid Duplicate Issues

(0) ShareShare
ReportReport
Posted on by 1,695

Hi

I am having some issues with a sub-grid that was setup.

Under competitors I wanted to add in a sub grid to accounts to allow for accounts to be added in under each competitor. To do this I created a new entity (Competitor Account)

4314.3.PNG

So in the competitor entity, users can search and add in accounts.

The problem I have is that the sub grid only seems to let one account be added to one competitor.  So for example if we have

  1. Account 1
  2. Account 2
  3. Account 3
  4. Account 4

They can all be added into the lookup for competitor A. But when I go to competitor B I am unable to tag any of the 4 accounts. If I had another account (Account 5) that can be added to competitor B with no issues.

The error message dynamics is giving is "the record is already associated with another record"

So my question is, is there a way to overcome this? All im looking for the competitor entity is to show a connection to an account. Some will all share the same account and so I need to be able to tag/lookup same records.

Any ideas?

*This post is locked for comments

I have the same question (0)
  • sitchey Profile Picture
    1,695 on at

    i created a new N:N relationship from accounts to competitor. However am unsure how to make this work as needed?

    Would I just create a new lookup field on competitors to accounts?

  • sitchey Profile Picture
    1,695 on at

    Thanks Guido

    My issue now is that the sub grid is now just showing all accounts, and doesn't have the ability to add a record - just simply shows the full list

    When i switch the subgrid to show only related records there are no accounts shown

  • Suggested answer
    Community Member Profile Picture
    on at

    Kieran,

    I am not sure if this will help in this situation, but I had a similar issue showing the subgrid for contacts associated to the account while in an opportunity form. The subgrid either showed me all contacts if I selected accounts, or none if I selected related because the contacts are related to the account instead of the opportunity. To get around this, I had to override the subgrids results using javascript below.

    function updateAccountContactSubGrid() {

          var relatedContacts = document.getElementById("ACCOUNTCONTACTS"); // Your Grid Unique Name

       var lookupfield = new Array;

       var lookupid;

       //Get the lookup field

       lookupfield = Xrm.Page.getAttribute("parentaccountid").getValue(); // Filter Grid base on the lookup value

       //This will get the lookup field guid if there is value present in the lookup

       if (lookupfield != null) {

           lookupid = lookupfield[0].id;

       }

       //Else the function will return and no code will be executed.

       else {

           return;

       }

       //This method is to ensure that grid is loaded before processing.

       if (relatedContacts == null || relatedContacts.readyState != "complete") {

           //This statement is used to wait for 2 seconds and recall the function until the grid is loaded.

           setTimeout('updateAccountContactSubGrid()', 2000);

           return;

       }

       var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";

       fetchXml += "<entity name='contact'>";

       fetchXml += "<attribute name='fullname' />";

       fetchXml += "<attribute name='telephone1' />";

       fetchXml += "<attribute name='contactid' />";

       fetchXml += "<attribute name='new_role' />";

       fetchXml += "<attribute name='jobtitle' />";

       fetchXml += "<attribute name='emailaddress1' />";

       fetchXml += "<attribute name='parentcustomerid' />";

       fetchXml += "<order attribute='fullname' descending='false' />";

       fetchXml += "<filter type='and'>";

       fetchXml += "<condition attribute='parentcustomerid' operator='eq' uitype='account' value='" + lookupid + "' />";

       fetchXml += "</filter>";

       fetchXml += "</entity>";

       fetchXml += "</fetch>";

       //Setting the fetch xml to the sub grid.

       relatedContacts.control.SetParameter("fetchXml", fetchXml);

       //This statement will refresh the sub grid after making all modifications.

       relatedContacts.control.refresh();

    }

    I hope this helps!

  • sitchey Profile Picture
    1,695 on at

    Hi Guido

    Yes i tired changing the data source to show only related accounts. At the min all the subgrid shows is a blank area.

    Where do you add the relationship to the account? There is no add button on the subgrid. Do you have to add a new field on accounts to show a competitor?

  • sitchey Profile Picture
    1,695 on at

    yea that was my issue, i cant see a + button above the field

    The top one was my initial sub grid (with the duplicate issues) and it has a plus button.

    The below one is the new sub grid, but it has no + button

  • sitchey Profile Picture
    1,695 on at

    ok i think it was a view issue not showing the + button

    its showing now so going to test some more

    One other question. How can you remove/untag accounts from this view?

    When I click the  show associated accounts button I see a new window which lets me delete account. Does this delete the full account or the association?

    Obviously I want to just delete the associated and not the account

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans