Thanks Jack,
Here is the code:
......
// Set up the Web service objects
ProjectWebSvc.Project projectSvc = new
ProjectWebSvc.Project();
projectSvc.Url = PROJECT_SERVER_URI + PROJECT_SERVICE_PATH;
projectSvc.Credentials =
CredentialCache.DefaultCredentials;
QueueSystemWebSvc.QueueSystem q = new
QueueSystemWebSvc.QueueSystem();
q.Url = PROJECT_SERVER_URI + QUEUESYSTEM_SERVICE_PATH;
q.Credentials = CredentialCache.DefaultCredentials;
// Read the project you want
Console.WriteLine("Reading project from database");
Guid projectId = new
Guid("98980F23-F110-44B6-82D2-28A5091A5D51");
ProjectWebSvc.ProjectDataSet projectDs =
projectSvc.ReadProject(projectId,
ProjectWebSvc.DataStoreEnum.WorkingStore);
//ProjectWebSvc.ProjectDataSet projectDs =
projectSvc.ReadProjectEntities(projectId, PROJECT_ENTITY_TYPE_TASK,
ProjectWebSvc.DataStoreEnum.WorkingStore);
#endregion
#region Change task name and update
// Check out the project
Console.WriteLine("Checking out project");
projectSvc.CheckOutProject(projectId, sessionId,
SESSION_DESC);
// Make changes
ProjectWebSvc.ProjectDataSet.TaskRow taskRow;
//taskRow = projectDs.Task.FindByTASK_UIDPROJ_UID(new
Guid("590E8895-73D8-45C6-B92B-E2491A907121"), new
Guid("98980F23-F110-44B6-82D2-28A5091A5D51"));
taskRow = projectDs.Task.FindByTASK_UIDPROJ_UID(new
Guid("60944C97-80F1-41FC-8143-F320C670D941"), new
Guid("98980F23-F110-44B6-82D2-28A5091A5D51"));
ProjectWebSvc.ProjectDataSet.ProjectCustomFieldsRow
customRow;
projectDs.Task[taskRow.TASK_ID].TASK_NAME = "Newest change
11/26 12:30";
// Save the changes
Console.WriteLine("Saving changes to the database");
jobId = Guid.NewGuid();
projectSvc.QueueUpdateProject(jobId, sessionId, projectDs,
false);
WaitForQueue(q, jobId);
#endregion
#region Publish
// Publish the project
Console.WriteLine("Publishing project");
jobId = Guid.NewGuid();
projectSvc.QueuePublish(jobId, projectId, true,
String.Empty);
WaitForQueue(q, jobId);
#endregion
#region Check in
// Check in the project
Console.WriteLine("Checking in the project");
jobId = Guid.NewGuid();
projectSvc.QueueCheckInProject(jobId, projectId, false,
sessionId, SESSION_DESC);
WaitForQueue(q, jobId);
#endregion
.....
Excuse the hard coding. Basically I know a ProjectUID I want to test with.
I
will know this and the TaskUID, via SQL query. I find a task row on this,
use
its TASK_ID as you mentioned to mod regular task fields.
I can't seem to get to the CF easily and thought I would have to use
TaskCustomFieldsRow, that is were the trouble is for me. I am testing
looping
through the TaskCustomFields, this is a lot of data and I was looking for
a
better way to pinpoint my target Task's CFs for modification.
Thanks,
Duffman
Jack Dahlgren said:
Generally it is best practice to modify the task object itself rather
than
going to a row.
If you know the taskID then it should be simple to do this.
For example if you want to change something on the task with ID of 4 then
activeproject.tasks(4).Text1 = "foo" would work. It gets a bit more
complicated with enterprise custom fields, but addressing the task object
instead of some row on some view is a much better idea.
If you post the code sample so we can see what you are doing it is easier
to
give suggestions on how to do it better.
-Jack Dahlgren