none
Add tasks inside a project (Project Online) using JSOM RRS feed

  • Question

  • I am trying to add tasks inside a project in project online. I am able to checkout the project but when trying to add a new tasks, it is giving error "Cannot read property 'Add' of undefined". Below is the code :

        

    <script type="text/javascript" src="/_layouts/15/ps.js"></script>
    <script type="text/javascript">
    var draftProject;
    ExecuteOrDelayUntilScriptLoaded(CreateProject, "PS.js");
    function CreateProject() {    
    projContext = PS.ProjectContext.get_current();
    projects = projContext.get_projects();
    project = projects.getById('GUID');
    draftProject = project.checkOut();
    projContext.load(draftProject);
    projContext.executeQueryAsync(CreateNewTask, QueryFailed)
    }
    
    function CreateNewTask()
    {
    var taskcreate = new PS.TaskCreationInformation();
    taskcreate.set_name("New task");
    
    /*Error in below line*/
    
    draftProject.Tasks.Add(taskcreate);
    draftProject.Publish(true);
    projContext.load(draftProject.Tasks);
    }
    Any help will be highly appreciated. Thanks.
    Saturday, January 27, 2018 5:38 AM

Answers