Changing the Project Owner
Suppose you need to change the project owner as far as Project Server is concerned? This functionality comes out of the box in Project Server. You don’t need to write a custom PDS extension, a regular PDS call will handle it. First make a call to ProjectCodeValues.
<Request>
<ProjectCodeValues>
<ProjectID>524</ProjectID>
<AutoCheckout>1</AutoCheckout>
</ProjectCodeValues>
</Request>
Look in the below reply for the Owner column. You’ll notice that column UID of 99999 is Owner.
<Reply>
<HRESULT>0</HRESULT>
<STATUS>0</STATUS>
<UserName>John Smith</UserName>
<ProjectCodeValues>
<ProjectID>524</ProjectID>
<ProjectName>Huge Project.Published</ProjectName>
<ProjectCheckedout>0</ProjectCheckedout>
<ProjectCheckedoutUser>John Smith</ProjectCheckedoutUser>
<CurrencySymbol/>
<CurrencyPosition>0</CurrencyPosition>
<CurrencyDigits>2</CurrencyDigits>
<Columns>
<Column>
<Type>0</Type>
<UID>99999</UID>
<Name>Owner</Name>
<SelectionRequired>1</SelectionRequired>
<ValueUID>5</ValueUID>
<Value>pm1</Value>
<ValueList>
<ValueItem>
<ValueUID>1</ValueUID>
<Value>Administrator</Value>
</ValueItem>
<ValueItem>
<ValueUID>101</ValueUID>
<Value>John Smith</Value>
</ValueItem>
<ValueItem>
<ValueUID>106</ValueUID>
<Value>pm1</Value>
</ValueItem>
</ValueList>
</Column>
</Columns>
</ProjectCodeValues>
</Reply>
You can then make a call to ProjectCodeValuesUpdate for that UID (99999) to update it. The ValueUID corresponds to the Resource WUID. What the heck is a WUID? That is the Web UID, in other words it comes from the web tables. In the above reply the ValueList is some available WUIDs. So my statement about not needing an extension is only half true. If you need other WUIDs you would need to write an extension to get the WUID from UID. The SQL for the database call would be similar to:
CREATE PROCEDURE GetWResIDFromResID
@user_id INT
AS
BEGIN
SELECT wres_id FROM msp_web_resources
WHERE @user_id = res_euid
RETURN
END
GO
So finally to make the update, an example of the call would be:
<Request>
<ProjectCodeValuesUpdate>
<ProjectID>524</ProjectID>
<AutoCheckin>1</AutoCheckin>
<Columns>
<Column>
<UID>99999</UID>
<ValueUID>106</ValueUID>
</Column>
</Columns>
</ProjectCodeValuesUpdate>
</Request>
An interesting note is that Project Server changes the ValueID to ResUID. So if you make the ProjectCodeValues call again, ValueUID will be equal to the ResUID, not the WUID of 106 that you just inputted. Why? Just the magic of coding [:D].
Comments
- Anonymous
July 17, 2007
code works! big thanks! nice work!