Microsoft Dynamics 365 Blog

During my investigation of Dynamics Ax Project Integration functionality I run into following problem. When a resource (in my case Employee) has a ‘,’ (comma) in its name (field DirPartyTable,Name and this resource get synchronize with Ms Project Server the export will fail with error:


An error occurred while creating the Employee compound entity of EntityId:e6365f25-7485-46d5-8e4c-65cb480fac34, Name:”Name, Surname” in project server.

Error: System.Web.Services.Protocols.SoapException: ProjectServerError(s) LastError=ResourceNameInvalid Instructions:

Pass this into PSClientError constructor to access all error information at Microsoft.Office.Project.Server.WebService.Resource.CreateResources(ResourceDataSet rds, Boolean validateOnly, Boolean autoCheckIn) PSCLientError Output: ResourceNameInvalid


When we looked further it happens that MS Project Server does not allowed resources with comma sign in name (http://technet.microsoft.com/en-us/library/cc197599.aspx). So either we should rename resource or does not allowed such a resource to be integrated. Below you can find the code sample which gived user the error message that resource with sign ‘,’ cannot be synchronize with Project Server. The message will be shown when user selects checbox “Integrate to Project Server” is selected. You need to change: AOT\ Data Dictionary \ Tables\SyncEmplTable in method validateProjServerProperties


from :



private boolean validateProjServerProperties()
{
    SyncEmplTable syncEmplTable;
    SyncApp syncApp;
    EmplTable emplTable, emplTableSameName;
    DirPartyTable dirPartyTable, dirPartyTableSameName;
    ;
    syncApp = SyncApp::find(this.AppId);
    emplTable = EmplTable::find(this.EmplId);
    dirPartyTable = DirPartyTable::find(emplTable.PartyId);
    if(syncApp && syncApp.AppType == SyncAppType::ProjectServer)
    { // Check that an integrated employee with the same name as this integrated employee being updated does not exist
      select emplTableSameName where emplTableSameName.EmplId != emplTable.EmplId join syncEmplTable
        where syncEmplTable.EmplId == emplTableSameName.EmplId
     join dirPartyTableSameName
       where dirPartyTableSameName.PartyId == emplTableSameName.PartyId &&
       dirPartyTableSameName.Name == dirPartyTable.Name
      join syncApp
       where syncApp.AppId == syncEmplTable.AppId && syncApp.AppType == SyncAppType::ProjectServer;
        if(emplTableSameName)
        { // Employee %1 cannot be integrated to project server. An employee with the same name has already been integrated to project server. // Project server does not allow more than one employee with the same name.
          checkFailed(strfmt(“@SYS113508”, this.EmplId));
          return false;
       }
    } 
    return true; 
}


to



private boolean validateProjServerProperties()
{
    SyncEmplTable syncEmplTable;
    SyncApp syncApp;
    EmplTable emplTable, emplTableSameName;
    DirPartyTable dirPartyTable, dirPartyTableSameName;
    ;
    syncApp = SyncApp::find(this.AppId);
    emplTable = EmplTable::find(this.EmplId);
    dirPartyTable = DirPartyTable::find(emplTable.PartyId);
    if(syncApp && syncApp.AppType == SyncAppType::ProjectServer)
    { // Check that an integrated employee with the same name as this integrated employee being updated does not exist
      select emplTableSameName where emplTableSameName.EmplId != emplTable.EmplId join syncEmplTable
        where syncEmplTable.EmplId == emplTableSameName.EmplId
     join dirPartyTableSameName
       where dirPartyTableSameName.PartyId == emplTableSameName.PartyId &&
       dirPartyTableSameName.Name == dirPartyTable.Name
      join syncApp
       where syncApp.AppId == syncEmplTable.AppId && syncApp.AppType == SyncAppType::ProjectServer;
        if(emplTableSameName)
        { // Employee %1 cannot be integrated to project server. An employee with the same name has already been integrated to project server. // Project server does not allow more than one employee with the same name.
          checkFailed(strfmt(“@SYS113508”, this.EmplId));
          return false;
       } 
       //code added
       if (strFind(emplTable.name(), ‘,’,1,strLen(emplTable.name())))
        {
          checkFailed(strfmt(“Project serever does not allow , sign”, emplTable.name())); //you may change first string with created label
          return false;
        }
       //end of code added
    } 
    return true;
   }

We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!