Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Workflow (or whatever) to associate n:n entities

(0) ShareShare
ReportReport
Posted on by

Dear reader,
I'm struggling with a new requirement looking like this:

We have a n:n relationship with custom entity Project and systemuser (used as project teams).

As soon as a new CRM user is added, he/she should be added to several (10+, so a lot of manual labor with all possibilities for errors) project teams.

I would like to refrain from database triggers and SQL inserts (possible, since we have all on premise) and my client won't pay for a plugin developer (can't do that myself unfortunately, unless someone could point out a clear HowToForDummies).

Is this even possible in a workflow or using javascript? Any other ideas?

Thanks for thinking along with me!
Best regards,
Jeroen

*This post is locked for comments

  • Rafael Pennese Profile Picture
    Rafael Pennese 25 on at
    RE: Workflow (or whatever) to associate n:n entities

    I know this is an old thread, but I'm also struggling to make any of the mentioned Workflows work...There is no documentation on GWE, and the workflow only has 2 arguments, which confuses me...

    By the way, the GWE webpage has changed : incrementalgroup.co.uk/.../

    Could anyone help? I just need to clone records form the same entity, and I want all records from the source record's N:N relationship cloned to the new record

  • Aaliya Profile Picture
    Aaliya 10 on at
    RE: Workflow (or whatever) to associate n:n entities

    Hi..

    Can you elaborate how can we merge this to current solution.

    And is there a documentation available.

  • RE: Workflow (or whatever) to associate n:n entities

    Has anyone a documentation for the GWE toolkit? I'm trying to associate some records trough a N:N relationship. Practically i have to link the linked Locations of an older Offer to a new/cloned Offer.

    Thank you and Regards,

    Aurel

    3414.Capture1.PNG

    and this is the error i receive:

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Microsoft.Xrm.Sdk.InvalidPluginExecutionException: Microsoft.Xrm.Sdk.InvalidPluginExecutionException: An error occurred in the AssociateRecord workflow.
 at Gap.RecordFunctions.AssociateRecord.ExecuteBody(CodeActivityContext executionContext, InterfaceLogger logger, IOrganizationService service)
 at Gap.RecordFunctions.AssociateRecord.ExecuteBody(CodeActivityContext executionContext, InterfaceLogger logger, IOrganizationService service)
 at Gap.RecordFunctions.CodeActivityBase.Execute(CodeActivityContext executionContext)Detail:
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
    <ErrorCode>-2147220891</ErrorCode>
    <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
    <Message>Microsoft.Xrm.Sdk.InvalidPluginExecutionException: Microsoft.Xrm.Sdk.InvalidPluginExecutionException: An error occurred in the AssociateRecord workflow.&amp;#13;&amp;#10; at Gap.RecordFunctions.AssociateRecord.ExecuteBody(CodeActivityContext executionContext, InterfaceLogger logger, IOrganizationService service)&amp;#13;&amp;#10; at Gap.RecordFunctions.AssociateRecord.ExecuteBody(CodeActivityContext executionContext, InterfaceLogger logger, IOrganizationService service)&amp;#13;&amp;#10; at Gap.RecordFunctions.CodeActivityBase.Execute(CodeActivityContext executionContext)</Message>
    <Timestamp>2018-07-03T11:52:51.3009334Z</Timestamp>
    <InnerFault>
    <ErrorCode>-2147220970</ErrorCode>
    <ErrorDetails xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
    <Message>Plugin Trace:

    [Gap Record Functions: Gap.RecordFunctions.AssociateRecord]
    [Gap Record Functions (6.1.7.5): Gap.RecordFunctions.AssociateRecord]

    Error Message:

    Unhandled Exception: Microsoft.Crm.CrmException: Microsoft.Xrm.Sdk.InvalidPluginExecutionException: Microsoft.Xrm.Sdk.InvalidPluginExecutionException: An error occurred in the AssociateRecord workflow.
    at Gap.RecordFunctions.AssociateRecord.ExecuteBody(CodeActivityContext executionContext, InterfaceLogger logger, IOrganizationService service)
    at Gap.RecordFunctions.AssociateRecord.ExecuteBody(CodeActivityContext executionContext, InterfaceLogger logger, IOrganizationService service)
    at Gap.RecordFunctions.CodeActivityBase.Execute(CodeActivityContext executionContext)
    at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)
    at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)
    </Message>
    <Timestamp>2018-07-03T11:52:51.3009334Z</Timestamp>
    <InnerFault i:nil="true" />
    <TraceText i:nil="true" />
    </InnerFault>
    <TraceText i:nil="true" />
    </OrganizationServiceFault>

  • Demian Rashkovan Profile Picture
    Demian Rashkovan 130 on at
    RE: Workflow (or whatever) to associate n:n entities

    Hi Jeroen J,

    I have documentation for N-N assoiciation here: github.com/.../Associate%20Entity.md

    Ping me an issue in github if you need anything else.

    Hope this helps,

    Demian.

  • Suggested answer
    RE: Workflow (or whatever) to associate n:n entities

    Hi Jeroen J,

    work with N:N relations by workflow is a little bit tricky.

    Please proceed as follow:

    1) Implement a workflow to deal with list of entity (refer to this post https://community.dynamics.com/crm/f/117/p/259098/727269#727269)

    2) Use the following method to create N:N relation:

    public static void Associate(IOrganizationService svc, EntityReference parentref, EntityReference childref, string relationname)
    {
    	EntityReferenceCollection childrefcoll = new EntityReferenceCollection();
    	childrefcoll.Add(childref);
    
    	Relationship relationship = new Relationship(relationname);
    
    	svc.Associate(parentref.LogicalName, parentref.Id, relationship, childrefcoll);
    }

    Please let me know.

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Jeroen J Profile Picture
    Jeroen J on at
    RE: Workflow (or whatever) to associate n:n entities

    That did the trick, Ryan! GWE worked spotless! Thanks for your suggestions!

  • Verified answer
    Ryan Maclean Profile Picture
    Ryan Maclean 3,070 on at
    RE: Workflow (or whatever) to associate n:n entities

    There is also a workflow step in the Gap Workflow Essentials toolkit to associate entities - www.gapconsulting.co.uk/.../workflow-essentials

    You could also use Andrii Butenko's Ultimate Workflow Toolkit - github.com/.../releases

    With the UWT step, you need to set your record 2 reference using the following format {id: "GUID", entityType: "ENTITY LOGICAL NAME"}

    I've used both of these successfully in the past

  • Jeroen J Profile Picture
    Jeroen J on at
    RE: Workflow (or whatever) to associate n:n entities

    @Guillaume, thanks for your quick response, I'll take a deep dive into your suggestion!

    @Ryan, I already found this one, but it's lacking dummy documentation.. Just don't seem to get it to work...

  • Suggested answer
    Ryan Maclean Profile Picture
    Ryan Maclean 3,070 on at
    RE: Workflow (or whatever) to associate n:n entities

    You could use Demian Rasko's workflow tools which has a step to do N:N associate github.com/.../Dynamics-365-Workflow-Tools

  • Suggested answer
    RE: Workflow (or whatever) to associate n:n entities

    Hi,

    As you don't want to do it with plugin, you will need to do it with Javascript as it is imposible to create an AssociateREquest with OOTB Workflow.

    Here is a sample with the old Rest end Point:msdn.microsoft.com/.../hh372956%28v=crm.7%29.aspx;MSPPError=-2147217396

    Here you have a nice tool to build your associate queries: github.com/.../CRMRESTBuilder

    jlattimer.blogspot.ch/.../crm-rest-builder-2300-now-with-web-api.html

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,575 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans