Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Auditing Access team information

Posted on by Microsoft Employee

Hello,

I am using the Access team feature in my project. Unfortunately, customer came with a new requirement where we need to track when a user is either added or deleted from a given access team. 

I've tried to capture the event on a plugin using the "Associate" message , filtering out "systemuser" and "team" entities with no luck; It doesn't get triggered at all.  Has anybody encountered this problem before? I feel that the access team information is barely usable at all.. 

Thanks in advance ,

Jorge. 

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auditing Access team information

    Thanks for guiding me to that post. Seems that "AddUserToRecordTeam" message does the trick. Cool!

  • Verified answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: Auditing Access team information

    Interesting.. I bet I did something similar just a few months ago and it seemed to work. Maybe did not test it well enough?

    Somebody has mentioned AddMember message here:

    community.dynamics.com/.../147186

    Wondering if that would work

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auditing Access team information

    Hi Alex,

    First, thanks for your interest. I registered a plugin on "Associate" message with no primary and secondary entity defined. The code itself, as follows. I profiled the plugin and I got nothing when adding a new user to access team. On the other hand, I added a user to a "regular" team on Teams administration and the profiler got triggered. 

    EntityReference targetEntity = null;
    string relationshipName = string.Empty;
    EntityReferenceCollection relatedEntities = null;
    EntityReference relatedEntity = null;

    if (context.MessageName == "Associate") {

    // Get the "Relationship" Key from context

    if (context.InputParameters.Contains("Relationship")) {

    relationshipName = context.InputParameters["Relationship"].ToString().SchemaName;

    }

    // Check the "Relationship Name" with your intended one

    if (relationshipName != "teammembership_association") {

    return;

    }

    // Get Entity 1 reference from "Target" Key from context

    if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is EntityReference) {

    targetEntity = (EntityReference)context.InputParameters["Target"];

    }

    // Get Entity 2 reference from " RelatedEntities" Key from context

    if (context.InputParameters.Contains("RelatedEntities") && context.InputParameters["RelatedEntities"] is EntityReferenceCollection) {

    relatedEntities = context.InputParameters["RelatedEntities"] as EntityReferenceCollection;

    relatedEntity = relatedEntities[0];

    }

    if(
    (relatedEntity.LogicalName == "systemuser" && targetEntity.LogicalName == "team")
    ||
    (relatedEntity.LogicalName == "team" && targetEntity.LogicalName == "systemuser")
    )
    {
    // MY CODE HERE.
    }

    }

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: Auditing Access team information

    Hi Jorge,

     How did you register the plugin? Could you post the code, too? I am pretty sure the plugin should work..

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans