none
PS.EnterpriseResourceCollection.update() returns undefined

    Question

  • I'm trying to update the collection of enterprise resources in the Project Web App instance using JSOM, but .update() method returns undefined.
    I was originally trying to add a calendar exception to a specific resource, but I've removed all this and I'm just trying to update the collection now. Same error. 
    Here's my code:

        // Initialize the current client context.
        projContext = PS.ProjectContext.get_current();

        // Get the collection of enterprise resources.
        resources = projContext.get_enterpriseResources();

        // Register the request for information that you want to run on the server.
        projContext.load(resources, "Include(Id, Name, ResourceCalendarExceptions, IsGeneric)");

        // Run the request on the server.
        projContext.executeQueryAsync(UpdateResources, QueryFailed);

        function UpdateResources(response)
        {
            // Submit the request to update the collection on the server
            var updateJob = resources.update(); // returns undefined! <------------------
            projContext.waitForQueueAsync(updateJob, 10, IterateThroughResources);
        }

    Another example:

    function UpdateProjects()
    {
    // Get the projects collection.
    projects = projContext.get_projects();

    // Submit the request to update the collection on the server
    var updateJob = projects.update(); <--------------- THIS CODE WORKS!
    projContext.waitForQueueAsync(updateJob, timeoutSeconds, QueueJobSent);
    }

    function UpdateResources()
    {
    // Get the projects collection.
    resources = projContext.get_enterpriseResources();

    // Submit the request to update the collection on the server
    var updateJob = resources.update(); <---------------------- THIS RETURNS UNDEFINED!
    projContext.waitForQueueAsync(updateJob, timeoutSeconds, QueueJobSent);
    }

    Any idea why this might be?

    Monday, September 09, 2013 4:03 PM

Answers

  • Fixed it!

    I used executeQueryAsync instead of waitForQueueAsync and also enabled administrative permissions

    Hope it helps!

    • Marked as answer by gbarbitta Monday, September 09, 2013 7:14 PM
    Monday, September 09, 2013 7:07 PM