in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

akila's blog

Setting Project Owner Programmatically in Project Server 2003

When you create a project using Project Data Services (PDS) from a custom application, the project owner for the Project will be set as per the user logon with which the project was created. To change the Project Owner, PDS can be used and there is no need of writing an Extender.

Make a call to the ProjectCodeValues method:

<Request>
   <ProjectCodeValues>
      <ProjectID>100</ProjectID>
      <ProjectName>Project Owner.Published</ProjectName>
      <AutoCheckout>0</AutoCheckout>
   </ProjectCodeValues>
</Request>

AutoCheckOut can be set to 1, if you want to check out the project as well.

All the project outline codes and custom fields that are set in the system are returned along with the value set for the project. The code having the UID 99999 corresponds to the owner field.

Look in the below reply to find the owner column,
 
<Reply>
   <HRESULT>0</HRESULT>
   <STATUS>0</STATUS>
   <UserName>John Smith</UserName>
   <ProjectCodeValues>
      <ProjectID>100</ProjectID>
      <ProjectName>Project Owner.Published</ProjectName>
      <ProjectCheckedout>0</ProjectCheckedout>
      <ProjectCheckedoutUser>Akila Ananthanarayanan</ProjectCheckedoutUser>
      <CurrencySymbol>$</CurrencySymbol>
      <CurrencyPosition>0</CurrencyPosition>
      <CurrencyDigits>2</CurrencyDigits>
      <Columns>
         <Column>
            <Type>0</Type>
            <UID>99999</UID>
            <Name>Owner</Name>
            <SelectionRequired>1</SelectionRequired>
            <ValueUID>75</ValueUID>
            <Value>Owner</Value>
            <ValueList>
               <ValueItem>
                  <ValueUID>1</ValueUID>
                  <Value>Administrator</Value>
               </ValueItem>
               <ValueItem>
                  <ValueUID>125</ValueUID>
                  <Value>Owner</Value>
               </ValueItem>
               <ValueItem>
                  <ValueUID>145</ValueUID>
                  <Value>Owner1</Value>
               </ValueItem>
            </ValueList>
         </Column>
      </Columns>
   </ProjectCodeValues>
</Reply>

To change the owner for this project, the ProjectCodeValuesUpdate method of PDS can be used. The Value UID for this column 99999 refers to Web Resource Id (WRES_ID) of the resource to be set as Owner. Any person can be set as owner (its not restricted to the ones in the value list), by providing their WRES_ID as Value UID. The valuelist lists all the resources who belong to Administrators Security Group.

Note that the Reply string for ProjectCodeValues contains the ValueUID same as the RES_UID whereas while updating the WRES_ID needs to be set. To get the WRES_ID for a resource, PDS Extender can be used. A PDS Extender request can look like,

<Request>
 <GetWebResourceID>
  <ResourceName>Akila</ResourceName>
 </GetWebResourceID>
</Request>

Use the following stored procedure to get the Web Resource Id (WRES_ID) in SQL:

CREATE PROCEDURE GetWebResourceID
  @ResourceName varchar(255)
AS
BEGIN
 SELECT wres_id FROM msp_web_resources
 WHERE RES_NAME = @ResourceName
 for xml auto
END
GO

Since PDS reply is in Xml Format, the data from SQL has to returned in Xml Format. Xml Auto returns the dataset as Xml String. Now get the WRES_ID and make a call to ProjectCodeValuesUpdate method, supplying the new Web Resource Id. Before the method can be executed, the project has to checked out. To checkout the Project, AutoCheckOut can be set to 1 or ProjectCheckout method can be used.

<Request>
   <ProjectCodeValuesUpdate>
      <ProjectID>100</ProjectID>
      <AutoCheckin>1</AutoCheckin>
      <Columns>
         <Column>
            <UID>99999</UID>
            <ValueUID>138</ValueUID>
         </Column>
      </Columns>
   </ProjectCodeValuesUpdate>
</Request>

Now the Owner is set and project checked in. When you make another call to ProjectCodeValues method, the ValueUID contains the RES_UID of the resource whom you set as owner and not the WRES_ID (I know its a bit confusing, but that's the way its programmed).

Akila.

Comments

No Comments

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts