I am trying to access the calendar exception for each resource, but I'm having some trouble with the nested executeQueryAsync() calls.
Here's a piece of my code:
App.js
// Get the collection of enterprise resources.
function GetResources()
{
// Display a message to the user to show we are reading the resources.
$('#spanMessage').text('Reading resources...');
// 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.
projContext.load(resources);
// Run the request on the server.
projContext.executeQueryAsync(IterateThroughResources, QueryFailed);
}
function IterateThroughResources(response)
{
// Get the enumerator and iterate through the collection.
var enumerator = resources.getEnumerator();
while (enumerator.moveNext())
{
var resource = enumerator.get_current();
var resourceId = resource.get_id();
var resourceName = resource.get_name();
// Get the collection of calendar exceptions.
var exceptions = resource.get_resourceCalendarExceptions();
// Register the request for information that you want to run on the server.
projContext.load(exceptions);
projContext.executeQueryAsync(Function.createDelegate(this, function(){IterateThroughCalendarExceptions(resource, exceptions);}), QueryFailed);
}
}
function IterateThroughCalendarExceptions(resource, exceptions)
{
var enumerator = exceptions.getEnumerator();
while (enumerator.moveNext())
{
var exception = enumerator.get_current();
var name = exception.get_name();
}
}
But the fact that it's running asynchronous it's a problem, because the IterateThroughCalendarExceptions seems to always receive the same params.