MSP API bug?

J

JLE

Hi,

I wonder if anyone else has experienced this API bug and have any solution
or work-around for this issue...

When our application using MSP's API to add a new resource assignment to a
task, the Work value gets changed. But, if manually add a new resource
assignemtn to a task, the Work value does NOT get changed (Duration gets
changed instead).

It seems like it's because:

Manual Entry uses this formula ==> Task Duration = Work / (8 * Number of
resources assigned for the task)

MSP API uses this formula ==> Task Work = Task Duration * 8 * Number of
resource assigned for the task


So, wehn manually enter a resource Duration changes and if a new resource is
added via MSP API, then Work gets changed.


Anyone has a work around for this inconsistant behaviour?

Thank you for your comment in advance,

Jessica
 
R

Rod Gill

Can you show us your code for the assignment?

In Project, when you add a resource with Effort Driven on, work gets shared
so the duration reduces. Usually adding a resource with code produces the
same result.

--

Rod Gill
Project MVP

NEW!! Project VBA Book, for details visit: http://www.projectvbabook.com
 
J

JLE

private void createAssignment(ref PDSAssignment target)

{

// make sure references are linked up

if(null==target.ProjectResource)

{

target.ProjectResource =
m_task.Project.ProjectResources.FindProjectResource(target.ResourceId);

if(null==target.ProjectResource)

throw new
MSPException(MSPExceptionCode.ResourceUserNotFound);

}

if(null==target.Task)

{

target.Task = m_task;

if(null==target.Task)

throw new
MSPException(MSPExceptionCode.TaskNotFound);

}



// try to add

target.ProjectResource.Project.CheckOut();



XmlDocument requestDoc = new XmlDocument();

XmlDocument responseDoc = new XmlDocument();



XmlElement request = requestDoc.CreateElement("Request");

requestDoc.AppendChild(request);

XmlElement projectAssignmentsCreate =
requestDoc.CreateElement("ProjectAssignmentsCreate");

request.AppendChild(projectAssignmentsCreate);



XmlElement autoPublish =
requestDoc.CreateElement("AutoPublish");

projectAssignmentsCreate.AppendChild(autoPublish);

autoPublish.InnerText = "1";



XmlElement projectID =
requestDoc.CreateElement("ProjectID");

projectAssignmentsCreate.AppendChild(projectID);

projectID.InnerText =
Convert.ToString(target.ProjectResource.Project.ProjectId);



XmlElement assignments =
requestDoc.CreateElement("Assignments");

projectAssignmentsCreate.AppendChild(assignments);



XmlElement assignment =
requestDoc.CreateElement("Assignment");

assignments.AppendChild(assignment);



XmlElement valueNode = requestDoc.CreateElement("TaskUID");

assignment.AppendChild(valueNode);

valueNode.InnerText = Convert.ToString(target.Task.UID);



valueNode = requestDoc.CreateElement("ResourceUID");

assignment.AppendChild(valueNode);

valueNode.InnerText =
Convert.ToString(target.ProjectResource.UID);



//commented for Admin projects, otherwise returns 1024 PDS
error



/*

valueNode = requestDoc.CreateElement("Start");

assignment.AppendChild(valueNode);

valueNode.InnerText =
target.Start.ToString("yyyyMMddHHmmss");



valueNode = requestDoc.CreateElement("Finish");

assignment.AppendChild(valueNode);

valueNode.InnerText =
target.Finish.ToString("yyyyMMddHHmmss");

*/

m_connection.SendRequest(ref responseDoc, requestDoc);



String hresult =
m_connection.GetProperty(responseDoc,"Reply/HRESULT");

String status =
m_connection.GetProperty(responseDoc,"Reply/STATUS");

if ("1006"==status) //something must have checked it in
on us, try checking out and sending again before giving up

{

target.ProjectResource.Project.IsCheckedOutByUs =
false;

target.ProjectResource.Project.CheckOut();

m_connection.SendRequest(ref responseDoc, requestDoc);

hresult =
m_connection.GetProperty(responseDoc,"Reply/HRESULT");

status =
m_connection.GetProperty(responseDoc,"Reply/STATUS");

}

if ("0"!=hresult || "0"!=status)

throw new PDSException(Int32.Parse(status));



target.GetUID();

}



We are using the “ProjectAssignmentsCreate" API of MSP server to create the
new assignment.


Any advise is welcome. :)

Jessica
 
J

JB

Have you noticed different behavior when a task already has an assignment,
vs when it doesn't?

Work changes, the first time you actually assign a resource to a task.
After that, it respects the Task Type of Fixed Work/Units/Duration.

If you add an assignment to a task that doesn't have any resources assigned
yet,
 
J

JLE

You are correct. That behaviour is fine.

The weird scenario I have is when a task already has one resource
assignment. I get different results when I add one additional resource by
manual entry vs. add an additional resource via MSP Server API.

API seems to use different formula?


Jessica
 
R

Rod Gill

Sorry I asked!! The VB or VBA code for all this is probably 5 lines of code
and I don't read C any longer!

All you can do is review the PDS manuals. I have not learnt PDS as it seems
to be professional programmers only and Project Server 2007 uses PSI and PDS
will be gone. Unfortunately PSI seems to require professional skills as well
:)

What you do manually is what VB or VBA does, any difference must be an error
in the PDS system or how C gets compiled.

Sorry, I can't help any further. A way to prove PDS as the problem is to
write the same code in VBA (around 5 lines will do it), but if PDS is the
problems there is unlikely to be a fix as PDS has been made redundant.

--

Rod Gill
Project MVP

NEW!! Project VBA Book, for details visit: http://www.projectvbabook.com
 

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