简体   繁体   中英

Single-Value Extended Property is null - MS Graph SDK

I am looking to save hidden data to a Outlook 365 event. This is how I am currently doing it.

SingleValueLegacyExtendedProperty singleEP1 = new SingleValueLegacyExtendedProperty
{
    Id = "String " + "{" + Guid.NewGuid() + "} " + "Name " + "PlanningID",
    Value = appointment.PlanningId.ToString() == null ? "0" : appointment.PlanningId.ToString()
};

SingleValueLegacyExtendedProperty singleEP2 = new SingleValueLegacyExtendedProperty
{
    Id = "String " + "{" + Guid.NewGuid() + "} " + "Name " + "CustomerName",
    Value = appointment.CustomerName.ToString() == null ? "" : appointment.CustomerName.ToString()
};

SingleValueLegacyExtendedProperty singleEP3 = new SingleValueLegacyExtendedProperty
{
    Id = "String " + "{" + Guid.NewGuid() + "} " + "Name " + "ProjectName",
    Value = appointment.ProjectName.ToString() == null ? "" : appointment.ProjectName.ToString()
};

SingleValueLegacyExtendedProperty singleEP4 = new SingleValueLegacyExtendedProperty
{
    Id = "String " + "{" + Guid.NewGuid() + "} " + "Name " + "PresentationName",
    Value = appointment.PrestationName.ToString() == null ? "" : appointment.PrestationName.ToString()
};

When I use the call to get all calendar items:

ICalendarCalendarViewCollectionPage retrievedEvents = await graphClient
                                                        .Me
                                                        .Calendars["Calendar"]
                                                        .CalendarView
                                                        .Request(options)
                                                        .GetAsync();

I then get a NULL on Single-Value Extended Property.

You don't want to do this

 Id = "String " + "{" + Guid.NewGuid() + "} " + "Name " + "PlanningID",

using Guid.NewGuid() will just generated a random extended property in Exchange which if you do enough will lead to extended property exhaustion. The GUID you use here is important because you will need to specify it when you want to retrieve that property. So Pick one GUID and use that in every property you want to set for your application eg

Id = "String " + "{66f5a359-4659-4830-9070-00049ec6ac6e} " + "Name " + "PlanningID",

I then get a NULL on Single-Value Extended Property. Any help would be highly appreciated.

To retrieved the above Extended property you need to specify it in the request (note why using a specific GUID is important) eg

  ICalendarCalendarViewCollectionPage retrievedEvents = await graphserviceClient
                 .Me
                 .Calendars["Calendar"]
                 .CalendarView
                 .Request(options)
                 .Expand("SingleValueExtendedProperties($filter=Id eq 'String {66f5a359-4659-4830-9070-00049ec6ac6e} Name PlanningID')")
                 .GetAsync();

However unless your trying to interact with a legacy app using MAPI or EWS a better idea for this type of custom data is open extenstions https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/opentypeextension which avoids a lot of ugliness when you have multiple properties you want to work with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM