CSOM - Programmatically update task custom fields RRS feed

  • Question

  • Hello forum members,

    I'm writing a client application which purpose is:

    1. create a project on a 2013 pwa --> this function works with no issues

    2. add tasks to the project --> this function works with no issues

    At this point I can navigate my PWA and open the project with Project Professional: I can see all tasks. 

    3. update some task custom fields based on a table --> this is driving me crazy.

    I wrote the following function: it works without error, no exception is raised, but when I open the project all custom fields are empty.

    In My queued Job page i find two failed entries:

    1) Project Checkin Failed But Not Blocking Correlation 12% N/A Click to view the error details

    With this error detail:

    • CICONotCheckedOut:
      • CICONotCheckedOut (10102). Details: id='10102' name='CICONotCheckedOut' uid='0509d6fd-92e4-e511-813d-000d3a223c16'.
    • Queue:
      • GeneralQueueJobFailed (26000) - ProjectCheckIn.FailIfNotCheckedOutMessage. Details: id='26000' name='GeneralQueueJobFailed' uid='0609d6fd-92e4-e511-813d-000d3a223c16' JobUID='511133eb-92e4-e511-813d-000d3a223c16' ComputerName='e467a714-14dd-48cc-ad26-192d5c0d0e2a' GroupType='ProjectCheckIn' MessageType='FailIfNotCheckedOutMessage' MessageId='2' Stage='' CorrelationUID='6c48669d-2587-c0b9-d0e2-a835e7763e1d'. For more details, check the ULS logs on machine e467a714-14dd-48cc-ad26-192d5c0d0e2a for entries with JobUID 511133eb-92e4-e511-813d-000d3a223c16
    2) Project Site Update Failed But Not Blocking Correlation 0% N/A Click to view the error details

    With this error detail:

    • Queue:
      • GeneralQueueJobFailed (26000) - CreateWssSite.CreateWssSiteMessage. Details: id='26000' name='GeneralQueueJobFailed' uid='dde2fc03-93e4-e511-813d-000d3a223c16' JobUID='4d1133eb-92e4-e511-813d-000d3a223c16' ComputerName='e467a714-14dd-48cc-ad26-192d5c0d0e2a' GroupType='CreateWssSite' MessageType='CreateWssSiteMessage' MessageId='1' Stage='' CorrelationUID='6c48669d-2587-c0b9-d0e2-a835e7763e1d'. For more details, check the ULS logs on machine e467a714-14dd-48cc-ad26-192d5c0d0e2a for entries with JobUID 4d1133eb-92e4-e511-813d-000d3a223c16

    try { SqlConnection connection0 = new SqlConnection(ConnectionString); SqlCommand command0 = new SqlCommand("SELECT * FROM TABLE", connection0); connection0.Open(); SqlDataReader reader0 = command0.ExecuteReader(); using (ProjectContext projectContext = new ProjectContext(pwaPath)) { projectContext.Load(projectContext.Projects); projectContext.ExecuteQuery(); var projCollection = projectContext.LoadQuery(projectContext.Projects.Where(p => p.Name == projName)); projectContext.ExecuteQuery(); projectContext.Load(projectContext.CustomFields); projectContext.ExecuteQuery(); PublishedProject proj2Edit = projCollection.First(); DraftProject draftProj = proj2Edit.IsCheckedOut ? proj2Edit.Draft : proj2Edit.CheckOut(); projectContext.Load(draftProj, p => p.Tasks.Include(t => t.Id, t => t.Name, t => t.Parent)); projectContext.ExecuteQuery(); DraftTaskCollection tasks = draftProj.Tasks; projectContext.Load(tasks); projectContext.ExecuteQuery(); foreach(DraftTask task in tasks) { while (reader0.Read()) {


    var cfInternalName = projectContext.CustomFields.FirstOrDefault(q => q.Name == CUSTOMFIELDNAME).InternalName; task[cfInternalName] = reader0[CUSTOMFIELDNAME]; } } QueueJob job = projectContext.Projects.Update(); JobState jobstate = projectContext.WaitForQueue(job, 200); draftProj.Publish(true); projectContext.ExecuteQuery(); } } catch (Exception ex) { throw ex; }

    I know I'm missing something, but I don't know what.

    Monday, March 7, 2016 7:56 PM

All replies

  • The reason you are not seeing the error is that you are retrieving the <g class="gr_ gr_29 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling ins-del multiReplace" data-gr-id="29" id="29">jobstate</g> from the WaitForJob call but not doing anything with it. You should have something like this:

    /// <summary>
    /// Log to Console the job state for queued jobs
    /// </summary>
    /// <param name="jobState">csom jobstate</param>
    /// <param name="jobDescription">job description</param>
    private static void JobStateLog(csom.JobState jobState, string jobDescription)
    switch (jobState)
    case csom.JobState.Success:
    Console.WriteLine(jobDescription + " is successfully done.");
    case csom.JobState.ReadyForProcessing:
    case csom.JobState.Processing:
    case csom.JobState.ProcessingDeferred:
    Console.WriteLine(jobDescription + " is taking longer than usual.");
    case csom.JobState.Failed:
    case csom.JobState.FailedNotBlocking:
    case csom.JobState.CorrelationBlocked:
    Console.WriteLine(jobDescription + " failed. The job is in state: " + jobState);
    Console.WriteLine("Unkown error, job is in state " + jobState);


    As for why the call is failing you may need a "dummy workflow" (see: This got me past a similar error I was encountering.

    Tuesday, November 21, 2017 12:17 PM