Hello all,
I am writing a small Windows application that creates new task and assignmet programmatically under a specific project in EPM, depending on logged-on user into this app.
I have in EPM "Project1" and Resource1 and Resource2 as resources already added to this project team in PWA. No tasks exist yet under this project. On the CreateTask button on the form, i have written code to handle the creation of new assignment for logged-on user of course through PSI calling the CreateNewAssignmentWithWork and passing the needed parameters to the function from the form.
I logged on to the application as Resource1 and clicked the CreateTask button to add Task1 to project in EPM. I logged on asResource2 to be assigned on the same task Task1, and Resource2 got as well assigned on the same task with different planned hours, no prob.
I then re-logged in back to application as Resource2 to call the same function for the same taskTask1 and of course I was prompted with an error saying that this Task is already assigned to the resource in question.
I need a way to handle this through code, I mean I need to handle the fact that if logged-on user on application was resource1 and resource2 or any other resource and they are already assigned on an existing task "Task1", and they try to recall the "CreateNewAssignmentWithWork" function to be assigned to the same task, they won't be allowed.
Below you will find a piece of my code, where I need to have this check. I would appreciate any help. THanks a lot.
MOnz
// Get the assignment data for the task. for (int i = 0; i <= projectDs.Assignment.Count; i++) { if (projectDs.Assignment.Count == 0) { statusingClient.CreateNewAssignmentWithWork(sName, projGuid, taskGuid, assnGuid, sumTaskGuid, dtStart, dtFinish, workHrs, fMilestone, fAddToTimesheet, fSubmit, sComment); done = true; } else if (projectDs.Assignment.Count > 0) { if (projectDs.Assignment[i].TASK_NAME == "Task1") { if (projectDs.Assignment[i].RES_UID == myUid) { MessageBox.Show("You are already assigned on this task in EPM", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } else if (projectDs.Assignment[i].RES_UID != myUid) { taskGuid = projectDs.Assignment[i].TASK_UID; statusingClient.CreateNewAssignmentWithWork(sName, projGuid, taskGuid, assnGuid, sumTaskGuid, dtStart, dtFinish, workHrs, fMilestone, fAddToTimesheet, fSubmit, sComment); break; } } } else
{ statusingClient.CreateNewAssignmentWithWork(sName, projGuid, taskGuid, assnGuid, sumTaskGuid, dtStart, dtFinish, workHrs, fMilestone, fAddToTimesheet, fSubmit, sComment); done = true; break; } }