Access month wise "Budget Cost" of project task using CSOM RRS feed

  • Question

  • We are working on MS Project Server on premises and we want to retrieve month wise “Budget Cost” from project task (Highlighted same in screenshot).

    Below C# CSOM code we have developed to access the value of property provided in parameter for provide project and task:

    public string GetTaskValueByProperty(string ProjectName, string TaskName, string Property)
                    context = new ProjectContext(pwaInstanceUrl);
                    NetworkCredential netcred = new NetworkCredential(userName, passWord, domain);
                    context.Credentials = netcred;
                    // Load the project by provided name with propeties - IsCheckedOut, Name, ID            
                    context.Load(context.Projects, p => p.Where(c => c.Name == ProjectName).Include(i => i.IsCheckedOut, i => i.Name, i => i.Id));
                    // If no project founf or more than one project found with provided name then return
                    if (context.Projects.Count == 0)
                        return "No project found with provided name - " + ProjectName;
                    else if (context.Projects.Count > 1)
                        return "Multiple projects found with provided name - " + ProjectName;
                    // Load first project
                    PublishedProject project = context.Projects[0];
                    // Load task from project by provided name
                    context.Load(project.Tasks, t => t.Where(c => c.Name == TaskName));
                    // Check if single task found else return
                    if (project.Tasks.Count == 0)                
                        return "Provided Task not found with name - " + TaskName;
                    else if (project.Tasks.Count > 1)
                        return "Multiple tasks found with provided name - " + TaskName;
                    // Get task properties from project
                    PublishedTask task = project.Tasks[0];
                    // Convert property string to object property and get the value of it
                    PropertyInfo pinfo = typeof(PublishedTask).GetProperty(Property);
                    object value = pinfo.GetValue(task, null);
                    // Return value and property name
                    return Property + " - " + value.ToString();
                catch (Exception ex)
                    return "System Error - " + ex.Message.ToString();

    Please suggest what approach we should take to retrieve month wise budget cost of the task.

    Please let me know if there is something in PSI to achieve the same.

    Best Regards, Somnath

    Tuesday, April 25, 2017 6:27 PM

All replies