PSI TaskCustomFieldsRow

D

Duffman

All,

I am having troble with TaskCustomFieldsRow. I am writing in C#, I have used
projectDs.Task.FindByTASK_UIDPROJ_UID(..... to locate the row I want to
modify but am at a loss to get TaskCustomFieldsRow to work. I have a couple
of custom fields that need to be modified. I can see the fields via
projectDs.TaskCustomFields and DataTable Visualizer.

Am i going to have to loop through this everytime to locate my field to
change? I was hoping someone could give me direction on how to use
TaskCustomFieldsRow which I believe would narrow my looping down to the
fields on the row rather than all the fields on all the rows. Am I thinking
of this correctly?

Thanks,
Duffman
 
J

Jack Dahlgren

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
 
D

Duffman

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
 
R

Rui Dias

Hello Duffman,

I'm having the same problem.
Have you found a solution to this?
I've got the "same" code as you and I' m exactly as you were. We don't have
the projectDs.Tasks(i).Text1 = "aaaa"
Can you help me?

Thanks in advance,
Rui Dias

Duffman said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top