Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Is Microsoft.Dynamics.ProjectService.Plugins code public?

Posted on by

I needed to disabled one of the plugin steps (PreValidateProjectTeamMemberCreate )

So was looking for the code to know what really does, so I could build my own excluding the part I don't need, but I couldn't find it in GitHub, so I guess the answer is that is not open source code.

But just looking for your confirmation, thanks.

  • Verified answer
    apa Profile Picture
    apa 8,282 on at
    RE: Is Microsoft.Dynamics.ProjectService.Plugins code public?

    Jorge I strongly advise against disabling any OOTB plug-ins. Nevertheless, here's the decompiled code.

    // Decompiled with JetBrains decompiler
    // Type: Microsoft.Dynamics.ProjectService.Plugins.PreValidateProjectTeamMemberCreate
    // Assembly: Microsoft.Dynamics.ProjectService.Plugins, Version=3.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    
    using crm;
    using Microsoft.Dynamics.ProjectService.Common;
    using Microsoft.Dynamics.ProjectService.Common.Exceptions;
    using Microsoft.Dynamics.ProjectService.Common.Repository;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Query;
    using System;
    
    namespace Microsoft.Dynamics.ProjectService.Plugins
    {
      public class PreValidateProjectTeamMemberCreate : PluginBase
      {
        public PreValidateProjectTeamMemberCreate(string unsecure, string secure)
          : base(typeof (PreValidateProjectTeamMemberCreate))
        {
        }
    
        protected override void ExecuteCrmPlugin(LocalPluginContext localContext)
        {
          ProjectTeamMember projectTeamMember = localContext != null ? localContext.GetTargetEntityFromInputParameters() : throw ExceptionFactory.CreateArgumentNullExceptionWithParameterName(nameof (localContext));
          projectTeamMember.msdyn_bookableresourceid = projectTeamMember.msdyn_bookableresourceid != null ? projectTeamMember.msdyn_bookableresourceid : new EntityReference("bookableresource", BookableResourceRepository.GetGenericResourceId(localContext.OrganizationService));
          Guid id = projectTeamMember.msdyn_bookableresourceid.Id;
          if (projectTeamMember.msdyn_project == null)
            throw ExceptionFactory.CreateInvalidPluginExecutionException("MissingProjectReference", ExceptionCategory.Unexpected);
          if (projectTeamMember.IsGenericResource(localContext.OrganizationService))
            return;
          Project project = RepositoryFactory.GetRepository(localContext.OrganizationService).Retrieve(projectTeamMember.msdyn_project.Id, new ColumnSet(new string[1]
          {
            "msdyn_istemplate"
          }));
          bool? msdynIstemplate = project.msdyn_istemplate;
          if (msdynIstemplate.HasValue)
          {
            msdynIstemplate = project.msdyn_istemplate;
            if (msdynIstemplate.Value)
              throw ExceptionFactory.CreateInvalidPluginExecutionException("InvalidProjectAsItIsTemplate");
          }
          if (localContext.HasBeenInvokedFromMessage("msdyn_BookingResource"))
            return;
          TeamManager teamManager = new TeamManager();
          if (teamManager.TeamContainsTeamMember(teamManager.RetrieveExistingTeamMembersOnProject(localContext.OrganizationService, projectTeamMember.msdyn_project.Id), id) != Guid.Empty)
            throw ExceptionFactory.CreateInvalidPluginExecutionException("DuplicateResourcesErrorMessage");
          if (localContext.HasBeenInvokedFromMessage("msdyn_CopyProject"))
            return;
          BookableResourceState? stateCode = RepositoryFactory.GetRepository().Retrieve(id, new ColumnSet(new string[1]
          {
            "statecode"
          })).StateCode;
          BookableResourceState bookableResourceState = BookableResourceState.Inactive;
          if (stateCode.GetValueOrDefault() == bookableResourceState & stateCode.HasValue)
            throw ExceptionFactory.CreateInvalidPluginExecutionException("InactiveBookableResourceErrorOnProjectTeam");
        }
      }
    }

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans