waitForQueueAsync throws Sys.ArgumentNullException Value cannot be null. Parameter name: clientObject
-
10-12-2019 - |
Question
I'm trying to update a resource (using JSOM) by adding a calendar exception, but I'm getting a Sys.ArgumentNullException when running the request on the server
Here's a piece of 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)
{
// Initialize a CalendarExceptionCreationInformation object and specify properties.
var creationInfo = new PS.CalendarExceptionCreationInformation();
creationInfo.set_name("Vacations");
// Specify properties.
creationInfo.set_start("2013-09-20 00:00:00.000");
creationInfo.set_start("2013-09-21 00:00:00.000");
var resourceId = "XXX";
var resource = resources.getById(resourceId);
// Add the calendar exception to the collection.
resource.get_resourceCalendarExceptions().add(creationInfo);
// Submit the request to update the collection on the server
var updateJob = resources.update();
projContext.waitForQueueAsync(updateJob, 10, IterateThroughResources);
}
Solution
Fixed it!
I used executeQueryAsync
instead of waitForQueueAsync
and also enabled administrative permissions.
Hope it helps!
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange