none
how to get the newly added/update assignment details using Project Server Events? RRS feed

  • Question

  • Hi,

    I am creating a Ms Project VSTO add in where in i need to restrict a Project Manager from creating or updating tasks in a baselined Project such that the Total Work in the project will never exceed the Baseline Work.

    Though he can create new tasks in his project he should not be able to exceed the Baseline Work (For our case this is the Project Approved Budget). So if a manager wants to create new assignments he will have to reduce the work on other tasks or delete other tasks.

    For this, I need to get the latest updates on the Assignments in MS Project events like ProjectBeforeAssignmnetChange/ProjectAsssignmentNew or any other event and restrict the updates based on the updated value of Duration or Work or Resource Assignments.

    I want to know the approach to get this done.

    FYI, My organisation is using MS project for Project management after excluding the usage of Timesheets or status updates by any resource. 

    Regards,

    Agasthya


    agasthya

    Monday, April 9, 2018 11:40 AM

Answers

  • Please find below the code which i have written to get this done. Hope this helps someone. 

    private void Application_WindowSelectionChange(MSProject.Window Window, MSProject.Selection sel, object selType)
            {
                    if (Application.ActiveProject.BaselineWork != 0)
                    {
                        var Tasks = (from MSProject.Task ActProjtask in Application.ActiveProject.Tasks
                                     where ActProjtask != null
                                             && ActProjtask.OutlineLevel >= 3
                                     select new { ActProjtask.ID, ActProjtask.Work, ActProjtask.BaselineWork });
                        var TotalWork = Tasks.Sum(a => Convert.ToInt32(a.Work));
                        var TotalBaselineWork = Tasks.Sum(a => Convert.ToInt32(a.BaselineWork));
                        if (TotalWork > TotalBaselineWork)
                        {
                            Application.Undo(1);
                            MessageBox.Show("Action Prohibited: Total Work of tasks for your department cannot exceed the approved budget");
                            return;
                        }
                    }
            }

    Reference: https://groups.google.com/forum/#!searchin/microsoft.public.project/assignment$20new|sort:date/microsoft.public.project/45I3mPfgojI/hve0ffm3znIJ

    Regards

    Agasthya


    agasthya

    • Marked as answer by Agasthya.S.P Tuesday, April 10, 2018 5:16 AM
    Tuesday, April 10, 2018 5:15 AM