Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

assign resources to a task programmatically

$
0
0

hello forum members,

does anyone knows which field in "Assignment" table in Project dataset belongs to a resource name assigned to a task?

below is my code and I see a guid added in "RES_UID_OWNER" AND "RES_UID", but when I open this project in Project Server or Project 2013 - I don't see resources assigned to a task.

Any help is appreciated.

 backendProject.ProjectDataSet readProjDs = projectClient.ReadProjectEntities(projectUids, PROJECT_ENTITY_TYPE_TASK_AND_RESOURCE, backendProject.DataStoreEnum.WorkingStore);

                    backendProject.ProjectDataSet.AssignmentRow newAssignmentRow = readProjDs.Assignment.NewAssignmentRow();

                    Guid RES_UID = new Guid("a153f98d-3b7e-e311-aa5f-0050569d03ac");  //get resource id 
                    newAssignmentRow.ASSN_UID = Guid.NewGuid(); 
                    try
                    {
                        Guid newGuid = Guid.Parse(taskid);
                        Console.WriteLine("Converted {0} to a Guid", taskid);
                       
                        newAssignmentRow.TASK_UID = newGuid; //get the task id
                    }
                    catch (ArgumentNullException)
                    {
                        Console.WriteLine("The string to be parsed is null.");
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("Bad format: {0}", taskid);
                    }
                    
                    newAssignmentRow.PROJ_UID = projectUids;
                    newAssignmentRow.RES_UID = RES_UID; 
                    newAssignmentRow.RES_UID_OWNER = RES_UID;
                    
                    newAssignmentRow.ASSN_START_DATE = DateTime.Now;
                    newAssignmentRow.ASSN_FINISH_DATE = DateTime.Now.AddDays(2);
                                   

                    readProjDs.Assignment.AddAssignmentRow(newAssignmentRow);
                                      

                    //check the project back in
                    projectClient.QueueCheckInProject(jobId, projectUids, false, sessionId, SESSION_DESCRIPTION);


tatiana


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>