0

I'm trying to create a simple task in a Project, using Project Server 2013 CSOM. I have looked everywhere, but i couldn't find anything that would solve this issue.

I can create a new empty project just fine using CSOM, but i can't create tasks in it.

Any help will be appreciated.

0

Here is something you might try if you are still looking. This is powershell but will add tasks from a CSV file. You need the project Guid and task names. It created a parent task (Mine is hard coded but not necessary) then creates the sub tasks.
Here is the code:

cls

function Load_SPAddin()
{
$ver = $host | select version
if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = “ReuseThread”}
if ((Get-PSSnapin “Microsoft.SharePoint.PowerShell” -ErrorAction SilentlyContinue) -eq $null)
    {
    Add-PSSnapin “Microsoft.SharePoint.PowerShell”
    }
}

Load_SPAddin

#Lets open the CSV (CSV is faser than Excel) 
$TaskList = Import-CSV "C:\test.csv"
$PriorProjGUID = ""

FOREACH ($Task in $TaskList) 
{

# Get the project GUID from the file. "ProjectGUID" is the header name of the column in the CSV File
# And we will grab the task name as well since we are here
$ProjGUID = $Task.ProjectGUID
$TaskName = $Task.TaskName 
# Lets do this while the project is the same
If ($ProjGUID -ne $PriorProjGUID) 
{
 #let's save, publish and checkin the project if there is a new one in the list 
  If ($PriorProjGUID -ne "")
    {
        # Add the above dataset to project and publish and check in 
        $ProjSvcProxy.QueueAddToProject($NewJobGuid, $SessionGUID, $ProjDataSet, $false); 
        $ProjSvcProxy.QueuePublish($NewJobGuid, $PriorProjGuid, "true","") 
     ## Start-sleep 20 
        $ProjSvcProxy.QueueCheckInProject($NewJobGuid, $PriorProjGuid, $false, $SessionGuid, $SessionDescr); 
     }  

  #Let's set the project name to the prior projct name so we can track our loop
   $PriorProjGUID = $ProjGUID  


  # we will open the project in this seciton first we have to set session variables and the like 
    # Set our variables 
    $SessionGuid = [System.Guid]::NewGuid() 
    $SessionDescr = "Add tasks session"  
    #$NewJobGuid = [System.Guid]::NewGuid() 
    $EPMTYGUID = [system.guid]::empty 
    $PWAUrl = “http://YOURSITE/pwa” 


    # initiate the PSI Web Services 
    #Project Web Service 
    $ProjSvcURL = $PWAUrl + "/_vti_bin/PSI/Project.asmx?wsdl" 
    $ProjSvcProxy = New-WebServiceProxy -uri $ProjSvcURL -useDefaultCredential #-credential $Credential 
    $QSvcUrl = $pwaUrl + "/_vti_bin/PSI/QueueSystem.asmx?wsdl" 
    $QSvcProxy = New-WebServiceProxy -uri $QSvcUrl -useDefaultCredential #-credential $Credential 

    # Now let's check the project out 
     $ProjSvcProxy.CheckOutProject("$ProjGuid", $sessionGuid, $SessionDescr); 

    #give it a chance to check out 
    ##Start-sleep 30 

    # Add tasks.  
     $ProjDataset = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1_vti_bin_PSI_Project_asmx_wsdl.ProjectDataSet  

       #create a summary task
         $NewTaskGuid = [System.Guid]::NewGuid() 
         $NewTaskRow1 = $ProjDataSet.Task.NewTaskRow(); 
         $NewTaskRow1.PROJ_UID = $ProjGuid; 
         $NewTaskRow1.TASK_UID = $NewTaskGuid; 
         $NewTaskRow1.Task_IS_SUMMARY = 1;
         $NewTaskRow1.Task_OUTLINE_LEVEL = 1;
         $NewTaskRow1.TASK_DUR_FMT = 53;
         $NewTaskRow1.TASK_NAME = "EPR-ID: Asset Tasks";
         $NewTaskRow1.Task_DUR_IS_EST = 1;
       $ProjDataSet.Task.AddTaskRow($NewTaskRow1); 


  }



 $NewTaskGuid = [System.Guid]::NewGuid() 
 $NewTaskRow1 = $ProjDataSet.Task.NewTaskRow(); 
 $NewTaskRow1.PROJ_UID = $ProjGuid; 
 $NewTaskRow1.TASK_UID = $NewTaskGuid 
 $NewTaskRow1.TASK_DUR_FMT = 53; 
 $NewTaskRow1.TASK_DUR = 0;   
 $NewTaskRow1.TASK_NAME = $TaskName; 
 $NewTaskRow1.Task_OUTLINE_LEVEL = 2;
 $NewTaskRow1.TASK_START_DATE = '8/1/2015' #[datetime]::Now; 
 $ProjDataSet.Task.AddTaskRow($NewTaskRow1); 


}  

#Check in the last project
# Add the above dataset to project and publish and check in 
$ProjSvcProxy.QueueAddToProject($NewJobGuid, $SessionGUID, $ProjDataSet, $false); 
$ProjSvcProxy.QueuePublish($NewJobGuid, $ProjGuid, "true","") 
#  Start-sleep 5 
$ProjSvcProxy.QueueCheckInProject($NewJobGuid, $ProjGuid, $false, $SessionGuid, $SessionDescr); 
Echo "We are all Done but the Queue has to finish that will take some time"          

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.