none
Project Server Enterprise custom Field auto increment RRS feed

  • Question

  • In Project Server, I have an Enterprise custom field 'MyID'. This ECF is used while creating a new project. Presently, the user needs to manually input this value when creating a new project plan, but I have to modify it in such a way that MyID will auto increment when a new project plan is created. I know that modifying the project server reporting table will not be a good idea as it may render the data useless.

    How do I accomplish this? I am sure many people might have faced this issue while coping with Project Server. Wanted to hear feedbacks,workarounds.

    Appreciate any input. 


    • Edited by Sameer Shah Wednesday, July 3, 2013 6:59 PM
    Wednesday, July 3, 2013 6:59 PM

All replies

  • Create a custom event handler that is attached to one of the project save / publish events and updates via the Project Server API/Interface (PSI) the custom field value. Download the SDK for more information.

    2007 SDK: http://www.microsoft.com/en-us/download/details.aspx?id=2432
    2010 SDK: http://www.microsoft.com/en-us/download/details.aspx?id=15511
    2013 SDK: https://www.microsoft.com/en-us/download/details.aspx?id=30435


    www.umt.com

    Wednesday, July 3, 2013 8:18 PM
  • Sorry for late reply and thank you for giving me a nudge in the right direction. I was looking at the SDK and your advise meanwhile.

    I created a class library based off from the SDK's project event handlers examples. I added PSI service reference to the project. 'OnCreated' event, a member of one of the PS libraries was overridden. I called the PSI service reference in that function to update the ECF value - MyID (as the project has already been created at this point and an update to one of its column values would be possible). Was that something you advised?

    I get an error on QueueUpdateProject of Project.asmx webservice instance. It says project is checkout out to another user:

    public override void OnPublished(PSLib.PSContextInfo contextInfo, ProjectPostPublishEventArgs e)
            {

    base.OnPublished(contextInfo, e); try { bool isWindowsUser = true; projectServerUrl = PROJECTSERVER_WIN_URL; //Creating a new service client object ProjectDerived projectSvc = new ProjectDerived(); projectSvc.Url = projectServerUrl + "Project.asmx"; projectSvc.Credentials = CredentialCache.DefaultCredentials; projectSvc.CookieContainer = GetLogonCookie(); projectSvc.EnforceWindowsAuth = isWindowsUser; Guid myCustomFieldId = new Guid("<myguidnumber>"); //creating a new sessionId and a new jobId Guid jobId = Guid.NewGuid(); //indicator if you have to update the project Boolean updatedata = false; //loading project data from server //Every change on this dataset will be updated on the server! ProjectDataSet project = projectSvc.ReadProject(e.ProjectGuid, DataStoreEnum.WorkingStore); ProjectDataSet projectEntity = projectSvc.ReadProjectEntities(e.ProjectGuid, (1), DataStoreEnum.PublishedStore); //(1|32): 1 or 64 means either pick 1 or 64. These are entity types for Project and ProjectCustomFields respectively.Also use sessionId of service account Guid sessionId = projectEntity.Project[0].PROJ_SESSION_UID; foreach (ProjectDataSet.ProjectCustomFieldsRow row in project.ProjectCustomFields) { if (row.MD_PROP_UID == myCustomFieldId) { //if yes, write it into the container row.NUM_VALUE = 444; //and set the indicater updatedata = true; } } //update if you have changed anything if (updatedata) { bool validateOnly = false; projectSvc.QueueUpdateProject(jobId, sessionId, project, validateOnly); //ERRORS OUT HERE SAYING PROJECT CHECKOUT OUT TO OTHER USER //wait 4 seconds just to be sure the job has been done System.Threading.Thread.Sleep(4000); //create a new jobId to check in the project jobId = Guid.NewGuid(); //CheckIn bool force = false; string sessionDescription = "updated custom fields"; System.Threading.Thread.Sleep(4000); /* now the data is in the database * but the gui want display the new value * so we have to publish the project to display * the new data. * * Maybe this is weird, but it works for me. */ //again a new jobId to publish the project jobId = Guid.NewGuid(); bool fullPublish = true; // projectSvc.QueuePublish(jobId, e.ProjectGuid, fullPublish, null); //maybe we should wait again ;) System.Threading.Thread.Sleep(4000);


    Can anyone help resolve this or this a know bug in MS Project?


    Sameer Shah



    • Edited by Sameer Shah Sunday, July 21, 2013 7:05 PM add on
    Thursday, July 11, 2013 10:55 AM