0

In my project I access task fields the following way:

projContext.Load(proj, p => p.Tasks.Include(t => t.Id, t => t.Name,t => t.Work));
projContext.ExecuteQuery();

task.Work gives me the current value. My goal is to modify the value programatically, but there is no setter method in PublishedTask and compiler complains that the property is read-only. Is there a way to modify properties of PublishedTask class?

gmode
  • 3,601
  • 4
  • 31
  • 39

1 Answers1

0

I found a solution. First you need to check out the project and then you are able to make and push changes.

var proj = projContext.Projects.GetById("d7e63f89-47c0-e511-80d1-00155d4g5202");
DraftProject checkoutProj = proj.CheckOut();
projContext.Load(checkoutProj);
projContext.Load(checkoutProj, p => p.Tasks.Include(t => t.Id, t => t.Work));
projContext.ExecuteQuery();

task.Work = "25";
checkoutProj.Publish(true);
projContext.ExecuteQuery();
gmode
  • 3,601
  • 4
  • 31
  • 39