Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Assign records to ex manager when changing to new manager

Posted on by 445

Hi,

When a user's manager is changed, till that date all the records of that user should be automatically assigned to the ex manager and whatever the new records the user is creating, it only should be assigned to the new manager.

Is there a way to achieve this?

Thanks.

*This post is locked for comments

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Assign records to ex manager when changing to new manager

    Here is a sample link to how to create a plugin:

    msdn.microsoft.com/.../gg594416.aspx

    You can also download the Microsoft Dynamics CRM SDK, which has some samples there.

    Hope this helps.

  • Elangamban Profile Picture
    Elangamban 445 on at
    RE: Assign records to ex manager when changing to new manager

    I don't know about creating plugin, but I'll give it a try.

    Thanks.

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Assign records to ex manager when changing to new manager

    You can create a plugin that will execute on the Update of the User record (when the manager field changes).

    You will need to create an Pre-Image of the entity (before the change), so that you can get the old manager id.

    Within your plugin, call the ReassignObjectsSystemUserRequest as shown below:

    ReassignObjectsSystemUserRequest req = new ReassignObjectsSystemUserRequest();

    //The user who's records will be reassigned

    req.UserId = new Guid("ASSIGN_FROM_USER_GUID");

    //The new user to receive the records

    req.ReassignPrincipal = new EntityReference("systemuser", new Guid("ASSIGN_TO_USER_GUID"));

    ReassignObjectsSystemUserResponse resp = (ReassignObjectsSystemUserResponse)service.Execute(req);

    Hope this helps.

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans