none
Is there a way to read the "date" when the project was baseline using CSOM? RRS feed

  • Question

  • Hi All,

    I'm working on Project Online Environment. Have gone through the CSOM API, but I can read only the latest Baseline start and Finish dates with it. 

    I'm looking for the date when the baseline was applied. Any idea, is there a way to get it?

    When I open the schedule in MPP and click on SetBaseline option I can see the date when the baseline was applied (date was appended to the baseline name in the drop down). I need to read this date programatically using CSOM.

    -----------------------------------------------

    Rajkumar Allepu (MCP) , | https://sharepointprojectserver.com ** Please mark it as answer if my answer would resolved your issue.


    Friday, June 14, 2019 8:32 AM

Answers

  • I got the answer.

    Project baseline modified date field is available in OData feed. So have connected to Project Baselines using ODATA Rest using CSOM Web client and read the Project baseline modified date.

    Below is the code. May help to someone. Dependancy on JSON.Net.web Nugets, SharePoint Online CSOM

    protected void Page_Load(object sender, EventArgs e)
            {
                var webUri = new Uri(" Odata feed URL ");          
                var credentials = new SharePointOnlineCredentials(userName, SecurePassword(password));
                var obj = GetList(webUri, credentials);
                Response.Write(DateTime.Parse(obj["results"].FirstOrDefault()["ProjectBaselineModifiedDate"].ToString()).ToShortDateString());
            }

    public JToken GetList(Uri webUri,ICredentials credentials)
            {
                using (var client = new WebClient())
                {
                    client.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
                    client.Credentials = credentials;
                    client.Headers.Add(HttpRequestHeader.ContentType, "application/json;odata=verbose");
                    client.Headers.Add(HttpRequestHeader.Accept, "application/json;odata=verbose");
                    var endpointUri = webUri;
                    var result = client.DownloadString(endpointUri);
                    var t = JToken.Parse(result);
                    return t["d"];
                }
            }

    So with the above approach we can read Odata feed records with CSOM , just we need to point to the right data set with the required columns.


    Rajkumar Allepu (MCP) , | https://sharepointprojectserver.com ** Please mark it as answer if my answer would resolved your issue.

    Tuesday, June 18, 2019 5:10 AM