0

I'm trying to make an Office taskpane app, that can access a resources calendar exceptions, and display them to the user.

I managed to access the resources, I can get a lot of its fields, but not the calendar exceptions. It seems like, those are stored elsewhere, not in the Resource object, directly.

Some code snippets :

//First, I get the ID of a resource, that is clicked and store it in resourceGuid
function getSelectedResourceAsync() {
    Office.context.document.getSelectedResourceAsync(function (asyncResult) {
        if (asyncResult.status == Office.AsyncResultStatus.Succeeded) {
            resourceGuid = asyncResult.value;
        }
    });
}

Then I use this ID, to get the selected resources fields, like Name, Cost, Work etc. and display them in a textfield on the HTML taskpane. Example :

function getResourceFields() {
    text.value = "";
    //I get the name of the resource here, and have it displayed in the textfield
    Office.context.document.getResourceFieldAsync(resourceGuid, Office.ProjectResourceFields.Name,
        function (asyncResult) {
            if (asyncResult.status == Office.AsyncResultStatus.Succeeded) {
                text.value = text.value + "Resource name: " + asyncResult.value.fieldValue + "\n";
            }
        }
    );

//After this, I'm getting the ResourceCalendarGuid, which is a promising name for 
//the resources calendar, but I'm stuck with it. I didn't find a way to 
//actually access the resources calendar.

Office.context.document.getResourceFieldAsync(resourceGuid, Office.ProjectResourceFields.ResourceCalendarGUID,
        function (asyncResult) {
            if (asyncResult.status == Office.AsyncResultStatus.Succeeded) {
                calendarGuid = asyncResult.value.fieldValue;
            }
        }
    );
}

I would like to use this ResourceCalendarGUID to access the resources unique calendar, that has exceptions stored in it, and I would like to show these exceptions to the end-user, via the textfield on the html taskpane.

Thank you for your time!

Laureant
  • 979
  • 3
  • 18
  • 47
  • The Resource object has a Calendar property which in turn has a collection of Exceptions. I don't know how to write it in javascript, but in .net or vba it would look like this: `SelectedRes.Calendar.Exceptions(1).Start`. – Rachel Hettinger Oct 22 '14 at 21:58
  • Thank you for the answer! Sadly, the same structure does not apply to javascript. It's far more limited. But I hoped, maybe somehow there is a way... – Laureant Oct 23 '14 at 04:59

0 Answers0