Quantcast
Viewing all articles
Browse latest Browse all 5347

Update custom field value from Powershell - Project Server 2013

I have an environment with nearly 1000 project and the PMO just decided on a few new custom fields. They know the value they want and want the update scripted. 

It should be noted that this is for a custom field with a lookup table

I am having an issue with the update getting an error

Exception calling "QueueUpdateProject" with "4" argument(s): "ProjectServerError(s) LastError=CustomFieldInvalidUID Instructions: Pass this into PSClientError constructor to access all error information"
At line:50 char:13

Eventually this will be puling the data from a CSV with both the custom field value and the project GUID. 

Any thoughts would be helpful.

#Lets open the CSV (CSV is faser than Excel)
#$ProjList = Import-CSV "F:\Proj.csv"
$PriorProjGUID = ""
$ProjectSite = "http://MYSITE/PWA"
$svcPSProxy = New-WebServiceProxy -uri "$ProjectSite/_vti_bin/PSI/Project.asmx?wsdl" -useDefaultCredential
#$EPMTYGUID = [system.guid]::empty
$CustGuid = "2a7f87c6-b4b4-e511-9442-0050569a591e"
$DropGuid = "9CCA38A4-B4B4-E511-9442-0050569A591E"
$ProjGUID = "727CCF93-85B1-E511-9442-0050569A591E"
$sessionGuid = [System.Guid]::NewGuid()

$projectUid = $ProjGUID

write-host $projectUID

        #$project = $svcPSProxy.ReadProjectEntities($projectUid, 1 , "WorkingStore")
        $project = $svcPSProxy.ReadProject($Projectuid, 0)
            #$sessionGuid = [System.Guid]::NewGuid()
            #$jobGuid = [System.Guid]::NewGuid()
            Write-Host $project.Project.Proj_Name "will be updated"
           $CustomField = $project.ProjectCustomFields.NewProjectCustomFieldsRow()
            $CustomField.PROJ_UID = $projectUid #$sessionGuid
            $CustomField.CUSTOM_FIELD_UID = [System.Guid]::NewGuid()
            $CustomField.MD_PROP_UID = $DropGuid
            $CustomField.CODE_Value = $CustGuid
            #$CustomField.TEXT_VALUE = "Execution"
            $project.ProjectCustomFields.AddProjectCustomFieldsRow($CustomField)

            $jobGuid = [System.Guid]::NewGuid()
            $svcPSProxy.CheckOutProject($projectUid, $sessionGuid, "Updating Project")

            $jobGuid = [System.Guid]::NewGuid()
            $svcPSProxy.QueueUpdateProject($jobGuid, $sessionGuid, $project, $FALSE);

            $jobGuid = [System.Guid]::NewGuid()
            $svcPSProxy.QueuePublish($jobGuid, $projectUid, $FALSE, $EPMTYGUID);

            $svcPSProxy.QueueCheckInProject($jobGuid, $projectUid, $TRUE, $sessionGuid, "CheckIn Update...")       


        


Tasks









Viewing all articles
Browse latest Browse all 5347

Trending Articles



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